Esempio n. 1
0
        private void HandleIncomingData()
        {
            while (!isShutdownRequested)
            {
                byte[] buffer   = new byte[1024];
                int    received = receiveSocket.Receive(buffer);

                KNet_Packet packet = KNet.DeserializePacket(buffer, 0, received);

                if (packet.isReliable)
                {
                    KNet_Packet freeReliable = new KNet_Packet()
                    {
                        isReliable = false,
                        packetID   = packet.packetID,
                        rpcName    = "INTERNAL_FREE-RELIABLE",
                    };

                    SendPacket(freeReliable);
                }

                Console.WriteLine("Received Packet {0}", packet.rpcName);

                KNet.ExecutePacket(packet);
            }

            sendSocket.Close();
            sendSocket.Dispose();
            receiveSocket.Close();
            receiveSocket.Dispose();
        }
Esempio n. 2
0
File: KNet.cs Progetto: isaveu/KNet
        private void HandleIncomingData()
        {
            while (!isShutdownRequested)
            {
                while (client.Available <= 0)
                {
                    ;
                }

                byte[]      buffer   = new byte[1024];
                int         received = client.GetStream().Read(buffer, 0, buffer.Length);
                KNet_Packet packet   = KNet.DeserializePacket(buffer, 0, received);
                if (KNet.debug)
                {
                    Console.WriteLine("Received Packet {0}", packet.rpcName);
                }

                if (packet.rpcName == KNet.INTERNAL_LOGIN_SUCCESS)
                {
                    //Set account data
                    continue;
                }

                KNet.ExecutePacket(packet);
            }

            client.Close();
        }
Esempio n. 3
0
File: KNet.cs Progetto: isaveu/KNet
 private void ParsePacket(KNet_Packet packet)
 {
     if (packet.rpcName.StartsWith("RPC"))
     {
         if (IsUserActive(packet.sender))
         {
             SendPacket(packet);
         }
     }
     else if (packet.rpcName.StartsWith("CMD"))
     {
         KNet.ExecutePacket(packet);
     }
 }
Esempio n. 4
0
 private void ParsePacket(KNet_Packet packet)
 {
     originOfCurrentProcessedPacket = packet.origin;
     if (packet.rpcName.StartsWith("RPC"))
     {
         if (IsUserActive(packet.origin))
         {
             SendPacket(packet);
         }
     }
     else if (packet.rpcName.StartsWith("CMD"))
     {
         KNet.ExecutePacket(packet);
     }
     else if (packet.rpcName == "INTERNAL_FREE-RELIABLE")
     {
         KNet.FreeReliablePacket(packet.packetID);
     }
 }