protected void HandlerData(NetworkConnection conn) { if (conn.recvLen < sizeof(Int32)) { Debug.Log("Can not get message size" + conn.recvLen.ToString()); return; } Array.Copy(conn.readBuff, conn.lenBytes, sizeof(Int32)); conn.msgLen = BitConverter.ToInt32(conn.lenBytes, 0); if (conn.recvLen < conn.msgLen + sizeof(Int32)) { Debug.Log("Package size error " + conn.recvLen.ToString() + ":" + (conn.msgLen + 4).ToString()); return; } INetworkProtocol msg = new ByteProtocol(); msg.Init(conn.ReceiveBytes); MessageQue.Enqueue(msg); int count = conn.recvLen - conn.msgLen - sizeof(Int32); Array.Copy(conn.readBuff, sizeof(Int32) + conn.msgLen, conn.readBuff, 0, count); conn.recvLen = count; if (conn.recvLen > 0) { HandlerData(conn); } }