Example #1
0
        public void HandleHandshake(HandshakePacket packet)
        {
            if (packet.Username != null && !IsLoggingIn)
            {
                IsLoggingIn = true;
                // check for baned users
                // if (banlist.Contains(client)) {
                //    client.SendPacket(new KickPacket() { message = "You'r BANNED!!!! Get lost!" };
                //    return;
                // }

                Console.WriteLine("Received Login for User " + packet.Username);

                Console.WriteLine("Send Handshake back!");
                SendPacket(new HandshakePacket(packet.Username));

                Console.WriteLine("Send Player Information");
                LoadPlayer();
                SendPlayerInfo();

                Console.WriteLine("Send Pattern");
                SendPattern();

                LastSendKeepAliveStamp = DateTime.Now.Ticks;

                Console.WriteLine("Finished Init. Send KeepAlive");
                KeepAlivePacket keepAlive = new KeepAlivePacket {TimeStamp = LastSendKeepAliveStamp};
                SendPacket(keepAlive);
            }
        }
Example #2
0
        public static void ReadKeepAlive(Client client, PacketReader reader)
        {
            KeepAlivePacket ap = new KeepAlivePacket();
            ap.Read(reader);

            if (!reader.Failed)
            {
                Client.HandleKeepAlive(client, ap);
            }
        }
Example #3
0
 public static void HandleKeepAlive(Client client, KeepAlivePacket ap)
 {
     if (ap.TimeStamp + 3000 > DateTime.Now.Ticks)
     {
         //TODO: Client Timeout. Disconnect Player
     }
     else
     {
         //Keep Alive Response came within time
         Console.WriteLine("Timeout Check is okey.");
     }
 }
Example #4
0
        public static void HandleKeepAlive(Client client, KeepAlivePacket ap)
        {
            //Respond KeepAlive Packet to Server
            Console.WriteLine("Received Keep Alive");
            client.SendPacket(new KeepAlivePacket {TimeStamp = ap.TimeStamp});

            lock (client.WaitInitialPositionRequestLook)
            {
                if (client.WaitInitialPositionRequest)
                {
                    client.WaitInitialPositionRequest = false;
                    Monitor.PulseAll(client.WaitInitialPositionRequestLook);
                }
            }
        }