Пример #1
0
        public string ReadString(NetworkPacket packet)
        {
            string value = packet.ReadString();
            int    len   = Encoding.UTF8.GetByteCount(value);

            while (((len++) % 4) != 0)
            {
                packet.ReadByte();
            }
            return(value);
        }
Пример #2
0
        public string ReadErrorCode(NetworkPacket packet)
        {
            ushort attrLength = packet.ReadUShort();
            uint   bits       = packet.ReadUInt();
            uint   code       = bits & 0xFF;
            uint   codeClass  = (bits & 0x700) >> 8;
            string phrase     = packet.ReadString(attrLength - 4);

            while ((attrLength++) % 4 != 0)
            {
                packet.ReadByte();
            }
            return("Error (" + codeClass + code.ToString("D2") + "): " + phrase);
        }
Пример #3
0
        public override void ReadRequest(NetworkPacket packet)
        {
            segmentLen = 0;
            startPos   = packet.ReadUInt();

            //first stream segment
            if (startPos == 0)
            {
                uint totalBytes = packet.ReadUInt();
                command    = packet.ReadString();
                byteData   = new byte[totalBytes];
                segmentLen = packet.ReadUInt();

                byte[] bytes = packet.ReadBytes((int)segmentLen);
                SetBuffer(bytes, 0);

                return;
            }

            //subsequent stream segments
            segmentLen = packet.ReadUInt();
            byteData   = packet.ReadBytes((int)segmentLen);
        }
Пример #4
0
 public void Read(NetworkPacket packet)
 {
     username = packet.ReadString();
 }