Пример #1
0
 public Packet(NetConstants.PacketTypes packetType, byte[] data)
 {
     PacketType = packetType;
     DataSize   = data.Length;
     Bytes      = createByteBufferWithHeader(packetType, DataSize);
     data.CopyTo(Bytes, HeaderSize);
 }
Пример #2
0
        private byte[] createByteBufferWithHeader(NetConstants.PacketTypes packetType, int size)
        {
            var buffer = new byte[HeaderSize + size];

            buffer[0] = (byte)packetType;
            BitConverter.GetBytes(size).CopyTo(buffer, 1);
            return(buffer);
        }