コード例 #1
0
ファイル: GpcmClient.cs プロジェクト: ttitt/LoginEmulator
        private void HandleClient()
        {
            // If there is data in the stream, clear it out!
            if (Stream.HasData())
            {
                Stream.Read();
            }

            // Get our client endpoint and Log thier connection
            EndPoint ClientEP = Client.Client.RemoteEndPoint;

            Server.Log("[GPCM] Client Connected: {0}", ClientEP);

            // Start by sending the server challenge
            SendServerChallenge();

            // While client remains connected, continuelly check for updates
            while (Client.Client.IsConnected())
            {
                Update();
                Thread.Sleep(200);
            }

            Server.Log("[GPCM] Client Disconnected: {0}", ClientEP);
            Dispose();
        }
コード例 #2
0
ファイル: GpcmClient.cs プロジェクト: ttitt/LoginEmulator
        /// <summary>
        /// Main listner loop. Keeps an open stream between the client and server while
        /// the client is logged in / playing
        /// </summary>
        private void Update()
        {
            if (Stream.HasData())
            {
                // TODO: process the 'getprofile' (returned at this point) data
                string   message = Stream.Read();
                string[] recv    = message.Split('\\');

                try
                {
                    switch (recv[1])
                    {
                    case "newuser":
                        HandleNewUser(recv);
                        Step++;
                        break;

                    case "login":
                        ProccessLogin(recv);
                        Step++;
                        break;

                    case "getprofile":
                        if (Step < 2)
                        {
                            SendProfile(false);
                            Step++;
                        }
                        else
                        {
                            SendProfile(true);
                        }
                        break;

                    case "updatepro":
                        UpdateUser(recv);
                        break;

                    case "logout":
                        LogOut();
                        break;

                    default:
                        Server.Log("Unkown Message Passed: {0}", message);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Starts the GPSP.gamespy.com listner for this client
        /// </summary>
        public void Start()
        {
            Server.Log("[GPSP] Client Connected: {0}", Client.Client.RemoteEndPoint);

            while (Client.Client.IsConnected())
            {
                Update();
                Thread.Sleep(200);
            }

            Server.Log("[GPSP] Client Disconnected: {0}", Client.Client.RemoteEndPoint);
            Dispose();
        }