public override void OnNetMsgBytes(IntPtr data, int len) { // CellRecvStream r = new CellRecvStream(data, len); CellReadStream r = new CellReadStream(data, len); // msg length Debug.Log(r.ReadUInt16()); // msg Type Debug.Log(r.ReadNetCmd()); Debug.Log(r.ReadInt8()); Debug.Log(r.ReadInt16()); Debug.Log(r.ReadInt32()); Debug.Log(r.ReadFloat()); Debug.Log(r.ReadDouble()); Debug.Log(r.ReadString()); Debug.Log(r.ReadString()); Int32[] arr = r.ReadInt32s(); for (int n = 0; n < arr.Length; n++) { Debug.Log(arr[n]); } r.Release(); }
public override void OnNetMsgBytes(IntPtr data, int len) { CellReadStream r = new CellReadStream(data, len); //注意:在构造函数中已经包含了消息长度和消息类型的解析,所以不需要再次解析 //消息长度 //UInt16 n1 = r.readUInt16(); //Debug.Log(n1); //消息类型 //NetCMD n2 = r.readNetCMD(); //Debug.Log(n2); sbyte n3 = r.readInt8(); Debug.Log(n3); Int16 n4 = r.readInt16(); Debug.Log(n4); Int32 n5 = r.readInt32(); Debug.Log(n5); float n6 = r.readFloat(); Debug.Log(n6); double n7 = r.readDouble(); Debug.Log(n7); string s1 = r.readString(); Debug.Log(s1); string s2 = r.readString(); Debug.Log(s2); Int32[] arr = r.readInt32s(); for (int i = 0; i < arr.Length; i++) { Debug.Log(arr[i]); } }