public override void Deserialize(ref PacketInStream Data) { long DicData = Data.ReadEncoded7Bit(); int KeyType; int ValueType; int Count; PacketInStream.Decode3Parameters(DicData, out KeyType, out ValueType, out Count); Dictionary <ISerializableField, ISerializableField> Dic = new Dictionary <ISerializableField, ISerializableField>(); Log.Debug("DicBit", "KeyType=" + KeyType + ",ValueType=" + ValueType + ",Count=" + Count); for (int i = 0; i < Count; ++i) { Log.Debug("DicBit", "Deserialise : Index=" + i + ",Type=" + KeyType); ISerializableField Key = PacketProcessor.ReadField(ref Data, i, KeyType); ISerializableField Value = PacketProcessor.ReadField(ref Data, i, ValueType); if (Key != null && Value != null) { Dic.Add(Key, Value); } } val = Dic; }
public static ISerializableField ReadField(ref PacketInStream Stream) { long FieldData = Stream.ReadEncoded7Bit(); if (FieldData < 0) { return(null); } int FieldType; int FieldIndex; if (!PacketInStream.Decode2Parameters(FieldData, out FieldType, out FieldIndex)) { return(null); } return(ReadField(ref Stream, FieldIndex, FieldType)); }
public override void Deserialize(ref PacketInStream Data) { long ListData = Data.ReadEncoded7Bit(); int ListType; int ListCount; PacketInStream.Decode2Parameters(ListData, out ListType, out ListCount); List<ISerializableField> Fields = new List<ISerializableField>(); Log.Success("Packet", "------> List : " + ListType + "("+ListCount+")"); for (int i = 0; i < ListCount; ++i) { ISerializableField Field = PacketProcessor.GetFieldType((EPacketFieldType)ListType); if (Field != null) { Field.Deserialize(ref Data); Fields.Add(Field); } } val = Fields; }
public override void Deserialize(ref PacketInStream Data) { long ListData = Data.ReadEncoded7Bit(); int ListType; int ListCount; PacketInStream.Decode2Parameters(ListData, out ListType, out ListCount); List <ISerializableField> Fields = new List <ISerializableField>(); Log.Success("Packet", "------> List : " + ListType + "(" + ListCount + ")"); for (int i = 0; i < ListCount; ++i) { ISerializableField Field = PacketProcessor.GetFieldType((EPacketFieldType)ListType); if (Field != null) { Field.Deserialize(ref Data); Fields.Add(Field); } } val = Fields; }
public override void Deserialize(ref PacketInStream Data) { long Opcode = Data.ReadEncoded7Bit(); PacketHandlerDefinition Handler = PacketProcessor.GetPacketHandler(Opcode); ISerializablePacket Packet = Activator.CreateInstance(Handler.GetClass()) as ISerializablePacket; Packet.Opcode = Opcode; ISerializableField Field = null; Log.Debug("Packet", "----------------------> New " + Opcode.ToString("X8")); while ((Field = PacketProcessor.ReadField(ref Data)) != null) { Log.Success("Packet", "------> ++T : " + Field.PacketType); Packet.AddField(Field.Index, Field); } Log.Debug("Packet", "----------------------> End "); Packet.ApplyToFieldInfo(); val = Packet; }
public override void Deserialize(ref PacketInStream Data) { long DicData = Data.ReadEncoded7Bit(); int KeyType; int ValueType; int Count; PacketInStream.Decode3Parameters(DicData, out KeyType, out ValueType, out Count); Dictionary<ISerializableField, ISerializableField> Dic = new Dictionary<ISerializableField, ISerializableField>(); Log.Debug("DicBit", "KeyType="+KeyType+",ValueType="+ValueType+",Count="+Count); for (int i = 0; i < Count; ++i) { Log.Debug("DicBit", "Deserialise : Index=" + i + ",Type=" + KeyType); ISerializableField Key = PacketProcessor.ReadField(ref Data,i,KeyType); ISerializableField Value = PacketProcessor.ReadField(ref Data, i, ValueType); if (Key != null && Value != null) Dic.Add(Key, Value); } val = Dic; }
public override void Deserialize(ref PacketInStream Data) { long Size = Data.ReadEncoded7Bit(); val = Data.Read((int)Size); }
public override void Deserialize(ref PacketInStream Data) { val = Data.ReadEncoded7Bit(); }
public bool ReadPacket() { if (Received.Count <= 0) { return(false); } if (!ReceiveCompress && !Crypted) { PacketInStream Packet = new PacketInStream(Received.ToArray(), Received.Count); long Size = Packet.ReadEncoded7Bit(); if (Size > Packet.Length) { return(false); } Received.RemoveRange(0, (int)(Packet.Position + Size)); ISerializablePacket Pack = PacketProcessor.ReadPacket(ref Packet); if (Pack != null) { Pack.OnRead(this); List <Cache_Info> Entries = CacheMgr.Instance.GetBinCache(Pack.Opcode, true); foreach (Cache_Info Entry in Entries) { SendCache(Entry.Type, (uint)Entry.CacheId); } } return(true); } if (Crypted) { byte[] Packet = Received.ToArray(); Received.Clear(); Decrypt(Packet); } if (ReceiveCompress) { int End = -1; while ((End = GetEndCompression(ref Decrypted)) >= 0) { byte[] ToUnCompress = new byte[End]; Buffer.BlockCopy(Decrypted.ToArray(), 0, ToUnCompress, 0, End); Decrypted.RemoveRange(0, End); byte[] Result = UnCompress(ToUnCompress); Log.Dump("Decrypted", Result, 0, Result.Length); PacketInStream Packet = new PacketInStream(Result, Result.Length); long Size = Packet.ReadEncoded7Bit(); if (Size > Packet.Length) { Log.Error("ReadPacket", "Size > Packet.Lenght,Size=" + Size + ",Lenght=" + Packet.Length); continue; } ISerializablePacket Pack = PacketProcessor.ReadPacket(ref Packet); if (Pack != null) { Pack.OnRead(this); List <Cache_Info> Entries = CacheMgr.Instance.GetBinCache(Pack.Opcode, true); foreach (Cache_Info Entry in Entries) { SendCache(Entry.Type, (uint)Entry.CacheId); } } } } return(false); }
public bool ReadPacket() { if (Received.Count <= 0) return false; if (!ReceiveCompress && !Crypted) { PacketInStream Packet = new PacketInStream(Received.ToArray(), Received.Count); long Size = Packet.ReadEncoded7Bit(); if (Size > Packet.Length) return false; Received.RemoveRange(0, (int)(Packet.Position+Size)); ISerializablePacket Pack = PacketProcessor.ReadPacket(ref Packet); if (Pack != null) { Pack.OnRead(this); List<Cache_Info> Entries = CacheMgr.Instance.GetBinCache(Pack.Opcode, true); foreach (Cache_Info Entry in Entries) SendCache(Entry.Type, (uint)Entry.CacheId); } return true; } if (Crypted) { byte[] Packet = Received.ToArray(); Received.Clear(); Decrypt(Packet); } if (ReceiveCompress) { int End = -1; while ((End = GetEndCompression(ref Decrypted)) >= 0) { byte[] ToUnCompress = new byte[End]; Buffer.BlockCopy(Decrypted.ToArray(), 0, ToUnCompress, 0, End); Decrypted.RemoveRange(0, End); byte[] Result = UnCompress(ToUnCompress); Log.Dump("Decrypted", Result, 0, Result.Length); PacketInStream Packet = new PacketInStream(Result, Result.Length); long Size = Packet.ReadEncoded7Bit(); if (Size > Packet.Length) { Log.Error("ReadPacket", "Size > Packet.Lenght,Size=" + Size + ",Lenght=" + Packet.Length); continue; } ISerializablePacket Pack = PacketProcessor.ReadPacket(ref Packet); if (Pack != null) { Pack.OnRead(this); List<Cache_Info> Entries = CacheMgr.Instance.GetBinCache(Pack.Opcode, true); foreach (Cache_Info Entry in Entries) SendCache(Entry.Type, (uint)Entry.CacheId); } } } return false; }
public static ISerializableField ReadField(ref PacketInStream Stream) { long FieldData = Stream.ReadEncoded7Bit(); if (FieldData < 0) return null; int FieldType; int FieldIndex; if (!PacketInStream.Decode2Parameters(FieldData, out FieldType, out FieldIndex)) return null; return ReadField(ref Stream, FieldIndex, FieldType); }