public Packet(NetConstants.PacketTypes packetType, byte[] data) { PacketType = packetType; DataSize = data.Length; Bytes = createByteBufferWithHeader(packetType, DataSize); data.CopyTo(Bytes, HeaderSize); }
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); }