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