示例#1
0
        void ServerRequestFunc()
        {
            _loadStatus = LoadStatus.FetchingFromServer;

            // Connect to server
            HClient client = new HClient("ServerRequestFunc");

            client.Connect(HClient.ServerAddress, HClient.ServerPort);
            client.OnGameInfoResponse += Client_OnGameInfoResponse;
            client.OnAccountResponse  += Client_OnAccountResponse;

            if (!client.Connected)
            {
                _loadStatus = LoadStatus.ServerUnreachable;
            }
            else
            {
                // Send request
                client.SendAccountRequest(_userName, _passWord, _accountCreate ? _userName : null, _oauthMode);

                // Wait for response
                while (client.Connected && _loadStatus == LoadStatus.FetchingFromServer)
                {
                    client.Update();
                    Task.Delay(10).Wait();
                }

                client.Close();
            }
        }