Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public static void ReadHandshake(Client client, PacketReader reader)
        {
            HandshakePacket hp = new HandshakePacket();
            hp.Read(reader);

            if (!reader.Failed)
            {
                client.HandleHandshake(hp);
            }
        }
Exemplo n.º 3
0
 public static void HandleHandshake(Client client, HandshakePacket hp)
 {
     //Handle Handshake
     Console.WriteLine("Received Handshake Packet back from Server :))");
 }
Exemplo n.º 4
0
        public void Start(IPEndPoint ipEndpoint)
        {
            _running = true;

            try
            {
                _socket.Connect(ipEndpoint);
            }
            catch (Exception)
            {
                Console.WriteLine("Error while connecting to Slaysher Server");
            }

            _socketAsyncArgs.Completed += RecvCompleted;
            _socketAsyncArgs.SetBuffer(_recvBuffer, 0, 2048);
            _receiveQueueReader.Start();
            Task.Factory.StartNew(RecvPacket);

            HandshakePacket handshake = new HandshakePacket {Username = _userName};
            SendPacket(handshake);
        }