public byte[] defaultPackMessage(object obj) { os.Position = 0; os2.Position = 0; B2OutputStream.writeObject(os, obj); int len = (int)os.Position; B2OutputStream.writeInt(os2, len); os2.Write(os.ToArray(), 0, len); int pos = (int)os2.Position; byte[] result = new byte[pos]; os2.Position = 0; os2.Read(result, 0, pos); return(result); }
/// <summary> /// Encodes the data.数据组包准备发送 /// </summary> /// <returns>The data.</returns> /// <param name="obj">Object.</param> public virtual byte[] encodeData(object obj) { os.Position = 0; os2.Position = 0; B2OutputStream.writeObject(os, obj); int len = (int)os.Position; B2OutputStream.writeInt(os2, len); os2.Write(os.ToArray(), 0, len); int pos = (int)os2.Position; byte[] result = new byte[pos]; os2.Position = 0; os2.Read(result, 0, pos); return(result); }