public static byte [] RecvPackage(Socket sock) { int len; JFPackage.PAG_HEAD head = new JFPackage.PAG_HEAD(); while (true) { len = recveSize(sock, PackageContext, JFPackage.HEAD_LENGTH, 0); if (len <= 0) { GameDebug.Log("head recveSize:" + len); break; } head = (JFPackage.PAG_HEAD)JFTools.BytesToStruct(PackageContext, head.GetType()); //GameDebug.Log("head.header:"+head.header+":"+head.no); if (head.header > 0) { len = recveSize(sock, PackageContext, head.header - JFPackage.HEAD_LENGTH, JFPackage.HEAD_LENGTH); //GameDebug.Log("body recveSize:"+len); if (len <= 0) { GameDebug.Log("body recveSize:" + len); break; } return(PackageContext); } else { GameDebug.Log("head.header <= 0:" + head.no); } } return(null); }
private void connectCallBack(IAsyncResult asyncConnect) { System.Action <object> cbConnected = (System.Action <object>)asyncConnect.AsyncState; if (cbConnected != null) { cbConnected((object)clientSocket); } JFPackage.PAG_HEAD h = new JFPackage.PAG_HEAD(); h.no = (uint)JFPackage.MSG_ID.CONNECTED; _curPackages.Add(h); }