Пример #1
0
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, clientId_);
     PacketUtil.encode(packet_, id_);
     PacketUtil.encode(packet_, password_);
 }
Пример #2
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("잘못된 패킷이 수신되었습니다");
                }

                packetProcee_.run(rowPacket);
            }
        }
Пример #3
0
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, ip_);
     PacketUtil.encode(packet_, port_);
     PacketUtil.encode(packet_, name_);
 }
Пример #4
0
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, clientId_);
     PacketUtil.encode(packet_, name_);
     PacketUtil.encode(packet_, result_);
 }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
 void PacketInterface.decode(byte[] packet, ref int offset)
 {
     roomNum = PacketUtil.decodeUInt64(packet, ref offset);
 }
Пример #8
0
 public static Int64 decodePacketType(Byte[] data, ref Int32 offset)
 {
     return(PacketUtil.decodeInt64(data, ref offset));
 }
Пример #9
0
 //-------------------------------------------------------------------//
 //---decoding 부분
 public static Int32 decodePacketLen(Byte[] data, ref Int32 offset)
 {
     return(PacketUtil.decodeInt32(data, ref offset));
 }
Пример #10
0
 public static void encode(MemoryStream packet, string str)
 {
     PacketUtil.encode(packet, (Int32)str.Length);
     packet.Write(Encoding.UTF8.GetBytes(str), 0, str.Length);
 }
Пример #11
0
 //-------------------------------------------------------------------//
 //--- encodeing 부분
 public static void encodeHeader(MemoryStream packet, Int64 headerType)
 {
     PacketUtil.encode(packet, headerType);
 }
Пример #12
0
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
 }
Пример #13
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);
 }
Пример #14
0
 void PacketInterface.decode(byte[] packet, ref int offset)
 {
     name_ = PacketUtil.decodestring(packet, ref offset);
 }
Пример #15
0
 void PacketInterface.decode(byte[] packet, ref int offset)
 {
     clientId_ = PacketUtil.decodeUInt64(packet, ref offset);
     name_     = PacketUtil.decodestring(packet, ref offset);
     result_   = PacketUtil.decodeByte(packet, ref offset);
 }
Пример #16
0
 void PacketInterface.decode(byte[] packet, ref int offset)
 {
     clientId_     = PacketUtil.decodeUInt64(packet, ref offset);
     oidAccountId_ = PacketUtil.decodeUInt64(packet, ref offset);
 }
Пример #17
0
 void PacketInterface.encode()
 {
     PacketUtil.encodeHeader(packet_, this.type());
     PacketUtil.encode(packet_, clientId_);
     PacketUtil.encode(packet_, oidAccountId_);
 }
Пример #18
0
 void PacketInterface.decode(byte[] packet, ref int offset)
 {
     clientId_ = PacketUtil.decodeUInt64(packet, ref offset);
     id_       = PacketUtil.decodestring(packet, ref offset);
     password_ = PacketUtil.decodestring(packet, ref offset);
 }