コード例 #1
0
ファイル: Client.Recv.cs プロジェクト: DynaStudios/Slaysher
        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);
            }
        }
コード例 #2
0
        public static void ReadHandshake(Client client, PacketReader reader)
        {
            HandshakePacket hp = new HandshakePacket();
            hp.Read(reader);

            if (!reader.Failed)
            {
                client.HandleHandshake(hp);
            }
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: DynaStudios/Slaysher
 public static void HandleHandshake(Client client, HandshakePacket hp)
 {
     //Handle Handshake
     Console.WriteLine("Received Handshake Packet back from Server :))");
 }
コード例 #4
0
ファイル: Client.cs プロジェクト: DynaStudios/Slaysher
        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);
        }