public void SendSerialized(ISerializablePacket Packet) { PacketOutStream Out = PacketProcessor.WritePacket(Packet); byte[] ToSend = Out.ToArray(); SendTCP(ToSend); List <Cache_Info> Entries = CacheMgr.Instance.GetBinCache(Packet.Opcode, false); foreach (Cache_Info Entry in Entries) { SendCache(Entry.Type, (uint)Entry.CacheId); } }
public override bool Serialize(ref PacketOutStream Data) { Log.Success("WriteList", "Serialize : " + val); if (val is List <ISerializablePacket> ) { List <ISerializablePacket> Packets = val as List <ISerializablePacket>; /*if (Packets.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Packet, Packets.Count); Data.WriteEncoded7Bit(ListData); foreach (ISerializablePacket Packet in Packets) { PacketProcessor.WritePacket(ref Data, Packet, false, true, true); } } else if (val is List <long> ) { List <long> Values = val as List <long>; /*if (Values.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Unsigned7BitEncoded, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.Unsigned7BitEncoded, (long)Values[i]); } } else if (val is List <uint> ) { List <uint> Values = val as List <uint>; /*if (Values.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Raw4Bytes, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.Raw4Bytes, (uint)Values[i]); } } else if (val is List <float> ) { List <float> Values = val as List <float>; /*if (Values.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Raw4Bytes, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.Raw4Bytes, Values[i]); } } else if (val is List <string> ) { List <string> Strs = val as List <string>; /*if (Strs.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.ByteArray, Strs.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Strs.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.ByteArray, (string)Strs[i]); } return(true); } else if (val is List <ISerializableField> ) { List <ISerializableField> Strs = val as List <ISerializableField>; if (Strs.Count <= 0) { return(false); } ISerializableField Field = Strs[0]; long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)Field.PacketType, Strs.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Strs.Count; ++i) { PacketProcessor.WriteField(ref Data, Strs[i].PacketType, Strs[i].val); } return(true); } else { return(false); } return(true); }
public override bool Serialize(ref PacketOutStream Data) { return(PacketProcessor.WritePacket(ref Data, (ISerializablePacket)val, false, true, true)); }