public static int SerializedSize(Packet obj) { return obj.SerializedSize(); }
public static byte[] Serialize(Packet obj) { return obj.Serialize(); }
public void Write(Packet packet) { byte[] bytes = packet.Serialize(); _connection.Write(bytes, bytes.Length); }
public byte[] Serialize() { var buffer = new byte[SerializedSize()]; int offset = 0; var sizeBytes = Serializer.Serialize(_list.Count); sizeBytes.CopyTo(buffer, offset); offset += sizeof(int); foreach (var item in _list) { var packet = new Packet(item); var data = packet.Serialize(); data.CopyTo(buffer, offset); offset += data.Length; } return buffer; }
public void Send(string key, Packet packet) { _sendQByKey[key].Enqueue(packet); }