void Start() { Debug.Log("hi"); NetMsg msg = new NetMsg(); msg.MessageName = "1024"; msg.MessageBody = new Dictionary<string, BaseMsg>(); BaseMsg bmsg = new BaseMsg(); bmsg.DoubleVal = 1027; msg.MessageBody.Add("helloworld", bmsg); byte[] arr = NetCoding.Serialize(msg); Debug.Log(arr); NetMsg newmsg = NetCoding.Deserialize(arr); Debug.Log(newmsg.MessageName); Debug.Log(newmsg.MessageBody["helloworld"].DoubleVal); }
public void Read (TProtocol iprot) { iprot.IncrementRecursionDepth(); try { bool isset_msgType = false; TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.I32) { MsgType = (VariableType)iprot.ReadI32(); isset_msgType = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Bool) { BoolVal = iprot.ReadBool(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.Byte) { ByteVal = iprot.ReadByte(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 4: if (field.Type == TType.I32) { IntVal = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 5: if (field.Type == TType.Double) { DoubleVal = iprot.ReadDouble(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 6: if (field.Type == TType.String) { StrVal = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 7: if (field.Type == TType.String) { ByteArrVal = iprot.ReadBinary(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 8: if (field.Type == TType.Map) { { MapVal = new Dictionary<BaseMsg, BaseMsg>(); TMap _map0 = iprot.ReadMapBegin(); for( int _i1 = 0; _i1 < _map0.Count; ++_i1) { BaseMsg _key2; BaseMsg _val3; _key2 = new BaseMsg(); _key2.Read(iprot); _val3 = new BaseMsg(); _val3.Read(iprot); MapVal[_key2] = _val3; } iprot.ReadMapEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 9: if (field.Type == TType.List) { { ListVal = new List<BaseMsg>(); TList _list4 = iprot.ReadListBegin(); for( int _i5 = 0; _i5 < _list4.Count; ++_i5) { BaseMsg _elem6; _elem6 = new BaseMsg(); _elem6.Read(iprot); ListVal.Add(_elem6); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 10: if (field.Type == TType.Set) { { SetVal = new THashSet<BaseMsg>(); TSet _set7 = iprot.ReadSetBegin(); for( int _i8 = 0; _i8 < _set7.Count; ++_i8) { BaseMsg _elem9; _elem9 = new BaseMsg(); _elem9.Read(iprot); SetVal.Add(_elem9); } iprot.ReadSetEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); if (!isset_msgType) throw new TProtocolException(TProtocolException.INVALID_DATA); } finally { iprot.DecrementRecursionDepth(); } }
public void Read (TProtocol iprot) { iprot.IncrementRecursionDepth(); try { bool isset_MessageName = false; TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { MessageName = iprot.ReadString(); isset_MessageName = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Map) { { MessageBody = new Dictionary<string, BaseMsg>(); TMap _map13 = iprot.ReadMapBegin(); for( int _i14 = 0; _i14 < _map13.Count; ++_i14) { string _key15; BaseMsg _val16; _key15 = iprot.ReadString(); _val16 = new BaseMsg(); _val16.Read(iprot); MessageBody[_key15] = _val16; } iprot.ReadMapEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); if (!isset_MessageName) throw new TProtocolException(TProtocolException.INVALID_DATA); } finally { iprot.DecrementRecursionDepth(); } }