コード例 #1
0
        /// <summary>
        /// Sends a challenge request to the given player.
        /// </summary>
        /// <param name="username">The username of the player to be challenged.</param>
        /// <returns>The newly created details of the match. Null if unsuccessful.</returns>
        public async Task <ChessGame> ChallengePlayerAsync(string username)
        {
            DisposeGuard();
            if (!TryBeginInvoke())
            {
                return(null);
            }

            ChessGame chessGame;

            try
            {
                chessGame = await _client.ChallengePlayerAsync(_loginResult?.TokenString, username);
            }
            catch (TaskCanceledException)
            {
                TryEndInvoke();
                return(null);
            }

            if (chessGame != null)
            {
                await PollAsync();
            }

            TryEndInvoke();
            return(chessGame);
        }
コード例 #2
0
        public async Task <ChessGame> ChallengePlayer(string username)
        {
            await Login();

            return(await _client.ChallengePlayerAsync(JwtToken, username));
        }