示例#1
0
        /// <summary>
        /// Gets a new Steam Web API nonce
        /// </summary>
        /// <returns></returns>
        public async Task <string> GetWebUserNonceKey()
        {
            var nonce = await SendJobAsync <CMsgClientRequestWebAPIAuthenticateUserNonceResponse>(
                NetworkMessage.CreateProtobufMessage(MessageType.ClientRequestWebAPIAuthenticateUserNonce, null)).ConfigureAwait(false);

            SteamException.ThrowIfNotOK(nonce.eresult, "The request for a Web API user nonce key did not complete succesfully");
            return(nonce.webapi_authenticate_user_nonce);
        }
示例#2
0
        /// <summary>
        /// Returns the number of current players playing the specified game on Steam
        /// </summary>
        /// <param name="appId"></param>
        /// <returns>
        /// <para>
        /// A task that when awaited returns the number of players playing the specified app.
        /// </para>
        /// </returns>
        public async Task <int> GetNumberOfCurrentPlayersAsync(long appId)
        {
            if (appId < uint.MinValue || appId > uint.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(appId));
            }

            var message = NetworkMessage.CreateAppRoutedMessage(MessageType.ClientGetNumberOfCurrentPlayersDP, new CMsgDPGetNumberOfCurrentPlayers {
                appid = (uint)appId
            }, appId);
            var response = await SendJobAsync <CMsgDPGetNumberOfCurrentPlayersResponse>(message).ConfigureAwait(false);

            SteamException.ThrowIfNotOK(response.eresult, $"A request for the current player count of app ID {appId} did not complete succesfully. Result: {(Result)response.eresult}");
            return(response.player_count);
        }