Example #1
0
        public byte[] ToBytes(Blowfish blowfish = null)
        {
            byte[] toBytes = new byte[Size];

            byte[] header = new byte[0x10];
            header[0x00] = IsAuthenticated;
            header[0x01] = IsCompressed;
            Buffer.BlockCopy(BitConverter.GetBytes(Size), 0, header, 0x04, 0x02);
            header[0x06] = (byte)SubPacketList.Count;
            Buffer.BlockCopy(Server.GetTimeStampHex(), 0, header, 0x08, 0x04);

            int index = 0x10;

            Buffer.BlockCopy(header, 0, toBytes, 0, header.Length);

            foreach (SubPacket sp in SubPacketList)
            {
                Buffer.BlockCopy(sp.ToBytes(blowfish), 0, toBytes, index, sp.Size);
                index += sp.Size;
            }

            return(toBytes);
        }