Exemple #1
0
        public AuthPacket(byte[] data, int size)
        {
            stream = new BinaryReader(new MemoryStream(data));

            Header         = new AuthPacketHeader();
            Header.Message = Read <byte>(6);

            if (Read <bool>(1))
            {
                Header.Channel = (AuthChannel)Read <byte>(4);
            }

            Data = new byte[size];

            Buffer.BlockCopy(data, 0, Data, 0, size);
        }
Exemple #2
0
        public AuthPacket(AuthServerMessage message, AuthChannel channel = AuthChannel.None)
        {
            stream = new BinaryWriter(new MemoryStream());

            Header         = new AuthPacketHeader();
            Header.Message = (byte)message;
            Header.Channel = channel;

            var hasChannel = channel != AuthChannel.None;

            Write(Header.Message, 6);
            Write(hasChannel, 1);

            if (hasChannel)
            {
                Write((byte)Header.Channel, 4);
            }
        }
Exemple #3
0
        public AuthPacket(AuthServerMessage message, AuthChannel channel = AuthChannel.Authentication)
        {
            writeStream = new BinaryWriter(new MemoryStream());

            Header         = new AuthPacketHeader();
            Header.Message = (ushort)message;
            Header.Channel = channel;

            var hasChannel = channel != AuthChannel.Authentication;
            var msg        = Header.Message >= 0x7E ? (Header.Message >> (byte)channel) - 0x3F : Header.Message - 0x3F;

            Write(msg, 6);
            Write(hasChannel, 1);

            if (hasChannel)
            {
                Write((byte)Header.Channel, 4);
            }
        }