void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, clientId_);
     PacketUtil.encode(packet_, id_);
     PacketUtil.encode(packet_, password_);
 }
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, clientId_);
     PacketUtil.encode(packet_, name_);
     PacketUtil.encode(packet_, result_);
 }
Ejemplo n.º 3
0
        public void receive()
        {
            if (stream_.DataAvailable)
            {
                Byte[] packetByte = new Byte[client_.ReceiveBufferSize];
                Int32  offset     = 0;
                Int32  readLen    = stream_.Read(packetByte, offset, packetByte.Length);

                PacketObfuscation.decodingHeader(ref packetByte, sizeof(Int32));

                Int32 packetLen = PacketUtil.decodePacketLen(packetByte, ref offset);


                while (readLen < packetLen)
                {
                    Byte[] remainPacket = new Byte[client_.ReceiveBufferSize];
                    Int32  remainLen    = 0;
                    remainLen = stream_.Read(remainPacket, 0, remainPacket.Length);
                    Buffer.BlockCopy(remainPacket, 0, packetByte, readLen, remainLen);
                    readLen += remainLen;
                }
                Byte[] packetData = new Byte[client_.ReceiveBufferSize];

                Buffer.BlockCopy(packetByte, offset, packetData, 0, readLen - offset);
                PacketObfuscation.decodingData(ref packetData, packetData.Length);
                Packetinterface rowPacket = PacketUtil.packetAnalyzer(packetData);

                if (rowPacket == null && this.isConnected())
                {
                    Debug.Log("잘못된 패킷이 수신되었습니다.");
                }

                ContentsProcee_.run(rowPacket);
            }
        }
Ejemplo n.º 4
0
 void Packetinterface.encode()
 {
     PacketUtil.encodeHeader(stream, type);
     PacketUtil.encode(stream, accountId);
     PacketUtil.encode(stream, roomNumber);
     PacketUtil.encode(stream, userNumber);
 }
Ejemplo n.º 5
0
 public void Encode()
 {
     PacketUtil.EncodeHeader(_Packet, this.GetPacketType());
     PacketUtil.Encode(_Packet, ClientId);
     PacketUtil.Encode(_Packet, Name);
     PacketUtil.Encode(_Packet, Result);
 }
Ejemplo n.º 6
0
 void Packetinterface.encode()
 {
     PacketUtil.encodeHeader(stream, type);
     PacketUtil.encode(stream, userNumber);
     PacketUtil.encode(stream, pos_X);
     PacketUtil.encode(stream, pos_Y);
 }
Ejemplo n.º 7
0
 void Packetinterface.decode(byte[] packet, ref int offset)
 {
     oidAccountId_ = PacketUtil.decodeUInt64(packet, ref offset);
     name_         = PacketUtil.decodestring(packet, ref offset);
     pos_X         = PacketUtil.decodefloat(packet, ref offset);
     pos_Y         = PacketUtil.decodefloat(packet, ref offset);
 }
Ejemplo n.º 8
0
 void Packetinterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, name_);
     PacketUtil.encode(packet_, pointX_);
     PacketUtil.encode(packet_, pointY_);
 }
Ejemplo n.º 9
0
 void Packetinterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, clientId_);
     PacketUtil.encode(packet_, oidAccountId_);
     PacketUtil.encode(packet_, result_);
 }
Ejemplo n.º 10
0
 public void Encode()
 {
     PacketUtil.EncodeHeader(_Packet, this.GetPacketType());
     PacketUtil.Encode(_Packet, Ip);
     PacketUtil.Encode(_Packet, Port);
     PacketUtil.Encode(_Packet, Name);
 }
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, ip_);
     PacketUtil.encode(packet_, port_);
     PacketUtil.encode(packet_, name_);
 }
Ejemplo n.º 12
0
 public void Encode()
 {
     PacketUtil.EncodeHeader(_Packet, this.GetPacketType());
     PacketUtil.Encode(_Packet, ClientId);
     PacketUtil.Encode(_Packet, Id);
     PacketUtil.Encode(_Packet, Password);
 }
Ejemplo n.º 13
0
        public static string DecodeString(Byte[] data, ref Int32 offset)
        {
            var    stringLength = PacketUtil.DecodeInt32(data, ref offset);
            string value        = Encoding.ASCII.GetString(data, offset, stringLength);

            offset += stringLength;
            return(value);
        }
Ejemplo n.º 14
0
 void Packetinterface.decode(byte[] packet, ref int offset)
 {
     clientId_ = PacketUtil.decodeUInt64(packet, ref offset);
     name_     = PacketUtil.decodestring(packet, ref offset);
     pointX_   = PacketUtil.decodefloat(packet, ref offset);
     pointY_   = PacketUtil.decodefloat(packet, ref offset);
     result_   = PacketUtil.decodeByte(packet, ref offset);
 }
Ejemplo n.º 15
0
 void Packetinterface.decode(byte[] packet, ref int offset)
 {
     ip_     = PacketUtil.decodestring(packet, ref offset);
     port_   = PacketUtil.decodeUInt32(packet, ref offset);
     name_   = PacketUtil.decodestring(packet, ref offset);
     pointX_ = PacketUtil.decodefloat(packet, ref offset);
     pointY_ = PacketUtil.decodefloat(packet, ref offset);
 }
Ejemplo n.º 16
0
 void Packetinterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, oidAccountId_);
     PacketUtil.encode(packet_, name_);
     PacketUtil.encode(packet_, pos_X);
     PacketUtil.encode(packet_, pos_Y);
 }
Ejemplo n.º 17
0
        public static string decodestring(Byte[] data, ref Int32 offset)
        {
            Int32  strLen = PacketUtil.decodeInt32(data, ref offset);
            string str    = System.Text.Encoding.ASCII.GetString(data, offset, strLen);

            offset += strLen;
            return(str);
        }
Ejemplo n.º 18
0
 void Packetinterface.decode(byte[] packet, ref int offset)
 {
     userNumber = PacketUtil.decodeInt32(packet, ref offset);
     steering   = PacketUtil.decodefloat(packet, ref offset);
     accel      = PacketUtil.decodefloat(packet, ref offset);
     footbrake  = PacketUtil.decodefloat(packet, ref offset);
     handbrake  = PacketUtil.decodefloat(packet, ref offset);
 }
Ejemplo n.º 19
0
        void Packetinterface.encode()
        {
            PacketUtil.encodeHeader(stream, type);
            PacketUtil.encode(stream, userNumber);
            PacketUtil.encode(stream, steering);
            PacketUtil.encode(stream, accel);
            PacketUtil.encode(stream, footbrake);

            PacketUtil.encode(stream, handbrake);
        }
Ejemplo n.º 20
0
        public static void encode(MemoryStream packet, Char[] value)
        {
            int len = (int)value.Length;

            PacketUtil.encode(packet, len);
            for (int i = 0; i < len; i++)
            {
                PacketUtil.encode(packet, value[i]);
            }
        }
Ejemplo n.º 21
0
        public static Char[] decodeCharArray(Byte[] data, ref Int32 offset)
        {
            Int32 strLen = PacketUtil.decodeInt32(data, ref offset);

            Char[] val = new char[strLen];

            for (int i = 0; i < strLen; i++)
            {
                val[i] = (char)PacketUtil.decodeByte(data, ref offset);
            }

            return(val);
        }
Ejemplo n.º 22
0
        public static IPacket PacketAnalyzer(Byte[] packetByte)
        {
            Int32   offset     = 0;
            Int64   packetType = PacketUtil.DecodePacketType(packetByte, ref offset);
            IPacket packet     = PacketFactory.GetPacket(packetType);

            if (packet == null)
            {
                return(null);
            }
            if (offset < packetByte.Length)
            {
                packet.Decode(packetByte, ref offset);
            }
            return(packet);
        }
Ejemplo n.º 23
0
        public void receive()
        {
            try {
                while (this.isConnected())
                {
                    Byte[] packetByte = new Byte[client_.ReceiveBufferSize];

                    Int32 offset  = 0;
                    Int32 readLen = stream_.Read(packetByte, offset, packetByte.Length);

                    // 패킷 난독화
                    PacketObfuscation.decodingHeader(ref packetByte, sizeof(Int32));

                    Int32 packetLen = PacketUtil.decodePacketLen(packetByte, ref offset);

                    while (readLen < packetLen)
                    {
                        Byte[] remainPacket = new Byte[client_.ReceiveBufferSize];
                        Int32  remainLen    = 0;
                        remainLen = stream_.Read(remainPacket, 0, remainPacket.Length);
                        Buffer.BlockCopy(remainPacket, 0, packetByte, readLen, remainLen);
                        readLen += remainLen;
                    }

                    Byte[] packetData = new Byte[client_.ReceiveBufferSize];
                    Buffer.BlockCopy(packetByte, offset, packetData, 0, readLen - offset);
                    PacketObfuscation.decodingData(ref packetData, packetData.Length);

                    PacketInterface rowPacket = PacketUtil.packetAnalyzer(packetData);
                    if (rowPacket == null && this.isConnected())
                    {
                        //MessageBox.Show("잘못된 패킷이 수신되었습니다", "error", MessageBoxButtons.OK);
                        //Application.Exit();
                    }
                    packetProcee_.run(rowPacket);
                }
                this.close();
            } catch (Exception e) {
                if (this.isConnected())
                {
                    //MessageBox.Show("잘못된 처리 : " + e.ToString(), "error", MessageBoxButtons.OK);
                    //Application.Exit();
                }
            }
        }
Ejemplo n.º 24
0
        public static PacketInterface packetAnalyzer(Byte[] packetByte)
        {
            Int32           offset     = 0;
            Int64           packetType = PacketUtil.decodePacketType(packetByte, ref offset);
            PacketInterface packet     = PacketFactory.getPacket(packetType);

            if (packet == null)
            {
                return(null);
            }

            // 데이터가 있으면 decoding 해서 넘기기
            if (offset < packetByte.Length)
            {
                packet.decode(packetByte, ref offset);
            }
            return(packet);
        }
Ejemplo n.º 25
0
        public void Receive()
        {
            try {
                while (IsConnected())
                {
                    byte[] packetByte = new byte[_Client.ReceiveBufferSize];
                    Int32  offset     = 0;
                    Int32  readLen    = _Stream.Read(packetByte, 0, packetByte.Length);
                    PacketObfuscation.DecodeHeader(ref packetByte, sizeof(Int32));
                    Int32 packetLen = PacketUtil.DecodePacketLen(packetByte, ref offset);

                    while (readLen < packetLen)
                    {
                        byte[] remainPacket = new byte[_Client.ReceiveBufferSize];
                        Int32  remainLen    = 0;
                        remainLen = _Stream.Read(remainPacket, 0, remainPacket.Length);
                        Buffer.BlockCopy(remainPacket, 0, packetByte, readLen, remainLen);
                        readLen += remainLen;
                    }

                    Byte[] packetData = new Byte[_Client.ReceiveBufferSize];
                    Buffer.BlockCopy(packetByte, offset, packetData, 0, readLen - offset);
                    PacketObfuscation.DecodeData(ref packetData, packetData.Length);

                    IPacket rowPacket = PacketUtil.PacketAnalyzer(packetData);
                    //IPacket rowPacket = PacketUtil.PacketAnalyzer(packetByte, ref offset, readLen);
                    if (rowPacket == null && IsConnected())
                    {
                        MessageBox.Show("잘못된 패킷이 수신됐습니다", "error", MessageBoxButtons.OK);
                        Application.Exit();
                    }
                    _PacketProcess.Run(rowPacket);
                }
                Close();
            } catch (Exception e) {
                if (IsConnected())
                {
                    MessageBox.Show("잘못된 처리:" + e.ToString(), "error", MessageBoxButtons.OK);
                    Application.Exit();
                }
            }
        }
Ejemplo n.º 26
0
        public static Packetinterface packetAnalyzer(Byte[] packetByte, int totalOffset)
        {
            Int32 offset     = 0;
            Int32 packetType = PacketUtil.decodeInt32(packetByte, ref offset);

            Packetinterface packet = PacketFactory.getPacket(packetType);

            if (packet == null)
            {
                Debug.Log("packet Analyzer failed");
                return(null);
            }

            // 데이터가 있으면 decoding 해서 넘기기
            if (offset < totalOffset)
            {
                packet.decode(packetByte, ref offset);
            }
            return(packet);
        }
Ejemplo n.º 27
0
 public void Encode()
 {
     PacketUtil.EncodeHeader(_Packet, this.GetPacketType());
 }
Ejemplo n.º 28
0
 public void Decode(byte[] packet, ref int offset)
 {
     ClientId = PacketUtil.DecodeUInt64(packet, ref offset);
     Name     = PacketUtil.DecodeString(packet, ref offset);
     Result   = PacketUtil.DecodeByte(packet, ref offset);
 }
Ejemplo n.º 29
0
 public void Decode(byte[] packet, ref int offset)
 {
     Name = PacketUtil.DecodeString(packet, ref offset);
     Text = PacketUtil.DecodeString(packet, ref offset);
 }
Ejemplo n.º 30
0
 public void Decode(byte[] packet, ref int offset)
 {
     ClientId     = PacketUtil.DecodeUInt64(packet, ref offset);
     OidAccountId = PacketUtil.DecodeUInt64(packet, ref offset);
 }