Esempio n. 1
0
 public static int SerializedSize(Packet obj)
 {
     return obj.SerializedSize();
 }
Esempio n. 2
0
 public static byte[] Serialize(Packet obj)
 {
     return obj.Serialize();
 }
Esempio n. 3
0
 public void Write(Packet packet)
 {
     byte[] bytes = packet.Serialize();
     _connection.Write(bytes, bytes.Length);
 }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 public void Send(string key, Packet packet)
 {
     _sendQByKey[key].Enqueue(packet);
 }