예제 #1
0
		/// <summary>
		/// (Async) (Requires <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Logs the SteamChatClient on to the Steam Chat Service under the context of the authenticated user (UserAuthenticator attached to the targeted SteamClient).
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <returns>
		///	Logs the SteamClient authenticated user on to the Steam Chat Service.
		/// </returns>
		/// <exception cref="SteamRequestException">SteamRequestException</exception>
		/// <exception cref="SteamAuthenticationException">SteamAuthenticationException</exception>
		public async Task LogOn( SteamClient client ) {

			IsManualDisconnection = false;

			try {

				IndicateConnectionState( ClientConnectionStatus.Connecting );

				client.IsAuthorizedCall( new Type[] {
					typeof( Authenticators.UserAuthenticator )
				} );

				SteamRequest request = new SteamRequest( "ISteamWebUserPresenceOAuth", "Logon", "v0001", HttpMethod.Post );
				ChatSession = SteamInterface.VerifyAndDeserialize<SteamChatSession>( ( await client.ExecuteAsync( request ) ) );
				LastMessageSentID = ChatSession.MessageBaseID;

				Authenticator = client.Authenticator;

				// Initialize Friends List
				FriendsList = await SteamCommunity.GetFriendsListAsync( this, ChatSession.SteamID );

				HasInitialized = true;

				BeginPoll();

			} catch( Exception e ) {
				IndicateConnectionState( ClientConnectionStatus.Disconnected );
				if( e is AggregateException && e.InnerException != null )
					throw e.InnerException;
				throw e;
			}

		}
예제 #2
0
		/// <summary>
		/// (Asynchronous) Returns global achievements overview for a specific game (in percentages)
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetGlobalAchievementPercentagesForApp_.28v0002.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <returns>A List of <see cref="GlobalAchievement"/> objects containing the achievement name and percentage.</returns>
		public async static Task<List<GlobalAchievement>> GetGlobalAchievementPercentagesForAppAsync( SteamClient client, int gameID ) {

			SteamRequest request = new SteamRequest( SteamAPIInterface.ISteamUserStats, "GetGlobalAchievementPercentagesForApp", SteamMethodVersion.v0002 );
			request.AddParameter( "gameid", gameID );

			return VerifyAndDeserialize<GetGlobalAchievementPercentagesForAppResponse>( ( await client.ExecuteAsync( request ) ) ).AchievementPercentages.Achievements;

		}
예제 #3
0
		/// <summary>
		/// (Requires UserAuthenticator, APIKeyAuthenticator) Returns a list of games a player owns along with some playtime information, if the profile is publicly visible.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetOwnedGames_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="getAppInfo">Include game name and logo information in the output?</param>
		/// <param name="getPlayedFreeGames">By default, free games are excluded (as technically everyone owns them). If flag is true, all games the user has played at some point will be returned.</param>
		/// <returns><see cref="OwnedGames"/> object containing information about the specified user's game collection.</returns>
		public static OwnedGames GetOwnedGames( SteamClient client, string steamID, bool getAppInfo = true, bool getPlayedFreeGames = true ) {
			try {
				return GetOwnedGamesAsync( client, steamID, getAppInfo, getPlayedFreeGames ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #4
0
		/// <summary>
		/// (Requires Authentication) Returns a list of games a player has played in the last two weeks.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetRecentlyPlayedGames_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="maxSelect">Optionally limit response to a certain number of games. Defaults to -1, meaning no limit is imposed.</param>
		/// <returns><see cref="OwnedGames"/> object containing information about the specified user's game collection.</returns>
		public static PlayedGames GetRecentlyPlayedGames( SteamClient client, string steamID, int maxSelect = -1 ) {
			try {
				return GetRecentlyPlayedGamesAsync( client, steamID, maxSelect ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #5
0
		/// <summary>
		/// Returns global achievements overview for a specific game (in percentages)
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetGlobalAchievementPercentagesForApp_.28v0002.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <returns>A List of <see cref="GlobalAchievement"/> objects containing the achievement name and percentage.</returns>
		public static List<GlobalAchievement> GetGlobalAchievementPercentagesForApp( SteamClient client, int gameID ) {
			try {
				return GetGlobalAchievementPercentagesForAppAsync( client, gameID ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #6
0
		/// <summary>
		/// Returns the latest of a game specified by its AppID.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetNewsForApp_.28v0002.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="appID">AppID of the game you want the news of.</param>
		/// <param name="count">How many news enties you want to get returned.</param>
		/// <param name="maxLength">Maximum length of each news entry.</param>
		/// <returns>An <see cref="AppNews"/> object.</returns>
		public static AppNews GetNewsForApp( SteamClient client, int appID, int count, int maxLength ) {
			try {
				return GetNewsForAppAsync( client, appID, count, maxLength ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #7
0
		/// <summary>
		/// Returns a list of achievements for the requested user by GameID (AppID)
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerAchievements_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <param name="returnLanguage">Desired language for the "name" and "description" properties of returned <see cref="Achievement"/> objects.</param>
		/// <returns><see cref="PlayerAchievements"/> object containing game name and list of <see cref="Achievement"/> objects.</returns>
		public static PlayerAchievements GetPlayerAchievements( SteamClient client, string steamID, int gameID, RequestedLangage returnLanguage ) {
			try {
				return GetPlayerAchievementsAsync( client, steamID, gameID, returnLanguage ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #8
0
		/// <summary>
		/// (Asynchronous) Returns the latest of a game specified by its AppID.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetNewsForApp_.28v0002.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="appID">AppID of the game you want the news of.</param>
		/// <param name="count">How many news enties you want to get returned.</param>
		/// <param name="maxLength">Maximum length of each news entry.</param>
		/// <returns>An <see cref="AppNews"/> object.</returns>
		public async static Task<AppNews> GetNewsForAppAsync( SteamClient client, int appID, int count, int maxLength ) {

			SteamRequest request = new SteamRequest( SteamAPIInterface.ISteamNews, "GetNewsForApp", SteamMethodVersion.v0002 );
			request.AddParameter( "appid", appID );
			request.AddParameter( "count", count );
			request.AddParameter( "maxlength", maxLength );

			return VerifyAndDeserialize<GetNewsForAppResponse>( ( await client.ExecuteAsync( request ) ) ).AppNews;

		}
예제 #9
0
		/// <summary>
		/// (Async) (Requires UserAuthenticator, APIKeyAuthenticator)
		/// Returns a list of games a player owns along with some playtime information, if the profile is publicly visible.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetOwnedGames_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="getAppInfo">Include game name and logo information in the output?</param>
		/// <param name="getPlayedFreeGames">By default, free games are excluded (as technically everyone owns them). If flag is true, all games the user has played at some point will be returned.</param>
		/// <returns><see cref="OwnedGames"/> object containing information about the specified user's game collection.</returns>
		public async static Task<OwnedGames> GetOwnedGamesAsync( SteamClient client, string steamID, bool getAppInfo = true, bool getPlayedFreeGames = true ) {

			client.IsAuthorizedCall( new Type[] { 
				typeof( Authenticators.UserAuthenticator ), // Executes in User Context (private)
				typeof( Authenticators.APIKeyAuthenticator ) // Executes in API context (public)
			} );

			SteamRequest request = new SteamRequest( SteamAPIInterface.IPlayerService, "GetOwnedGames", SteamMethodVersion.v0001 );
			request.AddParameter( "steamid", steamID, ParameterType.QueryString );
			request.AddParameter( "include_appinfo", ( ( getAppInfo ) ? 1 : 0 ), ParameterType.QueryString );
			request.AddParameter( "include_played_free_games", ( ( getPlayedFreeGames ) ? 1 : 0 ), ParameterType.QueryString );

			return VerifyAndDeserialize<GetOwnedGamesResponse>( ( await client.ExecuteAsync( request ) ) ).OwnedGames;

		}
예제 #10
0
		/// <summary>
		/// Returns a list of achievements for the requested user by GameID (AppID)
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerAchievements_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <returns><see cref="PlayerAchievements"/> object containing game name and list of <see cref="Achievement"/> objects.</returns>
		public static PlayerAchievements GetPlayerAchievements( SteamClient client, string steamID, int gameID ) {
			return GetPlayerAchievements( client, steamID, gameID, RequestedLangage.English );
		}
예제 #11
0
		/// <summary>
		/// (Async) (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns basic profile information for a list of 64-bit Steam IDs.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamIDs">List of 64 bit Steam IDs to return profile information for. If more than 100 is requested, requests will be executed in batches (API limit of 100 per call).</param>
		/// <returns>
		///	Returns a large amount of profile data for the requested users in the form of a <see cref="Player"/> object. 
		/// Some data associated with a Steam account may be hidden if the user has their profile visibility set to "Friends Only" or "Private". In that case, only public data will be returned.
		/// </returns>
		public async static Task<List<SteamUser>> GetUsersAsync( SteamClient client, SteamID[] steamIDs ) {

			client.IsAuthorizedCall( new Type[] {
				typeof( Authenticators.UserAuthenticator ),
				typeof( Authenticators.APIKeyAuthenticator )
			} );

			// GetUsers has an upper bound of 100 users per request, determine if aggregation is needed
			SteamID[][] chunks =
				steamIDs.Select( ( v, i ) => new { Value = v, Index = i } )
						.GroupBy( x => x.Index / 100 )
						.Select( group => group.Select( x => x.Value ).ToArray() )
						.ToArray();

			List<SteamUser> users = new List<SteamUser>();
			SteamRequest request;
			List<PlayerInfo> players;

			for( int i = 0; i < chunks.Length; i++ ) {

				if( client.Authenticator is Authenticators.UserAuthenticator ) {
					// ISteamUserOAuth provides a higher level of access (with User Authentication), assuming a personal relationship with the target user
					request = new SteamRequest( "ISteamUserOAuth", "GetUserSummaries", "v0001" );
					request.AddParameter( "steamids", String.Join<SteamID>( ",", steamIDs ) );
					players = VerifyAndDeserialize<GetPlayerSummariesContainer>( ( await client.ExecuteAsync( request ) ) ).Players;
				} else {
					request = new SteamRequest( "ISteamUser", "GetPlayerSummaries", "v0002" );
					request.AddParameter( "steamids", String.Join<SteamID>( ",", steamIDs ) );
					players = VerifyAndDeserialize<GetPlayerSummariesResponse>( ( await client.ExecuteAsync( request ) ) ).Response.Players;
				}

				foreach( var player in players ) {
					users.Add( new SteamUser {
						SteamID = player.SteamID,
						PlayerInfo = player
					} );
				}

			}

			return users;

		}
예제 #12
0
		/// <summary>
		/// (Async) (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns basic profile information for a given 64-bit Steam ID.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return profile information for.</param>
		/// <returns>
		///	Returns profile data for the requested user in the form of a <see cref="Player"/> object. 
		/// Some data associated with a Steam account may be hidden if the user has their profile visibility set to "Friends Only" or "Private". In that case, only public data will be returned.
		/// </returns>
		public async static Task<SteamUser> GetUserAsync( SteamClient client, SteamID steamID ) {
			return ( await GetUsersAsync( client, new SteamID[] { steamID } ) ).FirstOrDefault();
		}
예제 #13
0
		/// <summary>
		/// (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns basic profile information for a list of 64-bit Steam IDs.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamIDs">List of 64 bit Steam IDs to return profile information for. Up to 100 Steam IDs can be requested.</param>
		/// <returns>
		///	Returns a large amount of profile data for the requested users in the form of a <see cref="Player"/> object. 
		/// Some data associated with a Steam account may be hidden if the user has their profile visibility set to "Friends Only" or "Private". In that case, only public data will be returned.
		/// </returns>
		public static List<SteamUser> GetUsers( SteamClient client, SteamID[] steamIDs ) {
			try {
				return GetUsersAsync( client, steamIDs ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #14
0
 /// <summary>
 /// Authenticates the client with the Steam API.
 /// </summary>
 /// <param name="client">SteamClient instance to be authenticated.</param>
 /// <param name="request">Request requiring authentication.</param>
 private void AuthenticateClient( SteamClient client, ISteamRequest request )
 {
     if( Authenticator != null ) {
         Authenticator.Authenticate( client, request );
     }
 }
예제 #15
0
		public SteamChatClient( SteamClient client ) {
			this.SteamChatConnectionChanged += SteamChatConnectionChangeHandler;
			SteamClient = client;
		}
예제 #16
0
		/// <summary>
		/// (Async) (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns the friend list of any Steam user, provided the user's Steam Community profile visibility is set to "Public."
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <returns><see cref="SteamFriendsList"/> object containing a list of <see cref="SteamFriend"/> objects mapping to the Friend's list of the target user.</returns>
		public async static Task<SteamFriendsList> GetFriendsListAsync( SteamClient client, SteamID steamID ) {

			client.IsAuthorizedCall( new Type[] {
				typeof( Authenticators.UserAuthenticator ),
				typeof( Authenticators.APIKeyAuthenticator )
			} );

			SteamRequest request;
			List<SteamFriend> response;

			if( client.Authenticator is Authenticators.UserAuthenticator ) {
				// ISteamUserOAuth provides a higher level of access (with User Authentication), assuming a personal relationship with the target user
				request = new SteamRequest( "ISteamUserOAuth", "GetFriendList", "v0001" );
				request.AddParameter( "steamID", steamID.ToString() );
				response = VerifyAndDeserialize<SteamFriendsListResponse>( ( await client.ExecuteAsync( request ) ) ).Friends;
			} else {
				request = new SteamRequest( "ISteamUser", "GetFriendList", "v0001" );
				request.AddParameter( "steamID", steamID.ToString() );
				response = VerifyAndDeserialize<GetFriendsListResponse>( ( await client.ExecuteAsync( request ) ) ).FriendsList.Friends;
			}

			Dictionary<SteamID, SteamUser> users = new Dictionary<SteamID, SteamUser>();
			foreach( var friend in response ) {
				users.Add( friend.SteamID, new SteamUser {
					SteamID = friend.SteamID,
					FriendSince = friend.FriendSince,
				} );
			}

			return new SteamFriendsList {
				Friends = await GetBulkProfileDataAsync( client, users )
			};

		}
예제 #17
0
		/// <summary>
		/// (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns the friend list of any Steam user, provided the user's Steam Community profile visibility is set to "Public."
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <returns><see cref="SteamFriendsList"/> object containing a list of <see cref="SteamFriend"/> objects mapping to the Friend's list of the target user.</returns>
		public static SteamFriendsList GetFriendsList( SteamClient client, SteamID steamID ) {
			try {
				return GetFriendsListAsync( client, steamID ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #18
0
		/// <summary>
		/// (Asynchronous) Returns a list of stats for this user by GameID (App ID).
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetUserStatsForGame_.28v0002.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <returns><see cref="PlayerStats"/> object containing game name and list of <see cref="Stat"/> objects.</returns>
		public async static Task<PlayerStats> GetUserStatsForGameAsync( SteamClient client, string steamID, int gameID ) {

			SteamRequest request = new SteamRequest( SteamAPIInterface.ISteamUserStats, "GetUserStatsForGame", SteamMethodVersion.v0002 );
			request.AddParameter( "appid", gameID );
			request.AddParameter( "steamid", steamID );

			return VerifyAndDeserialize<GetUserStatsForGameResponse>( ( await client.ExecuteAsync( request ) ) ).PlayerStats;

		}
예제 #19
0
		/// <summary>
		/// Returns a list of stats for this user by GameID (App ID).
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetUserStatsForGame_.28v0002.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <returns><see cref="PlayerStats"/> object containing game name and list of <see cref="Stat"/> objects.</returns>
		public static PlayerStats GetUserStatsForGame( SteamClient client, string steamID, int gameID ) {
			try {
				return GetUserStatsForGameAsync( client, steamID, gameID ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #20
0
		/// <summary>
		/// (Asynchronous) Returns a list of achievements for the requested user by GameID (AppID)
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerAchievements_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <param name="returnLanguage">Desired language for the "name" and "description" properties of returned <see cref="Achievement"/> objects.</param>
		/// <returns><see cref="PlayerAchievements"/> object containing game name and list of <see cref="Achievement"/> objects.</returns>
		public async static Task<PlayerAchievements> GetPlayerAchievementsAsync( SteamClient client, string steamID, int gameID, RequestedLangage returnLanguage ) {

			SteamRequest request = new SteamRequest( SteamAPIInterface.ISteamUserStats, "GetPlayerAchievements", SteamMethodVersion.v0001 );
			request.AddParameter( "appid", gameID );
			request.AddParameter( "steamid", steamID );

			request.AddParameter( "l", GetLanguageFromEnum( returnLanguage ) );

			return VerifyAndDeserialize<GetPlayerAchievementsResponse>( ( await client.ExecuteAsync( request ) ) ).PlayerAchievements;

		}
예제 #21
0
		/// <summary>
		/// (Asynchronous) Returns a list of achievements for the requested user by GameID (AppID)
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerAchievements_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">AppID of the game you want the news of.</param>
		/// <returns><see cref="PlayerAchievements"/> object containing game name and list of <see cref="Achievement"/> objects.</returns>
		public async static Task<PlayerAchievements> GetPlayerAchievementsAsync( SteamClient client, string steamID, int gameID ) {
			return await GetPlayerAchievementsAsync( client, steamID, gameID, RequestedLangage.English );
		}
예제 #22
0
		/// <summary>
		/// (Requires Authentication) (Async) Returns the original owner's SteamID if a borrowing account is currently playing the specified game. Null if not borrowed, or the borrower isn't currently playing the game.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#IsPlayingSharedGame_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">GameID (AppID) of the game you're interested in querying.</param>
		/// <returns></returns>
		public async static Task<SharedGameData> IsPlayingSharedGameAsync( SteamClient client, string steamID, int gameID ) {

			SteamRequest request = new SteamRequest( SteamAPIInterface.IPlayerService, "IsPlayingSharedGame", SteamMethodVersion.v0001 );
			request.AddParameter( "steamid", steamID, ParameterType.QueryString );
			request.AddParameter( "appid_playing", gameID, ParameterType.QueryString );

			IsPlayingSharedGameObject obj = VerifyAndDeserialize<IsPlayingSharedGameResponse>( ( await client.ExecuteAsync( request ) ) ).IsPlayingSharedGame;

			if( String.IsNullOrEmpty( obj.LenderSteamID ) || obj.LenderSteamID == "0" ) {
				return new SharedGameData {
					IsUserPlayingSharedGame = false,
					GameOwnerSteamID = null,
					GameBorrowerSteamID = null
				};
			} else {
				return new SharedGameData {
					IsUserPlayingSharedGame = true,
					GameOwnerSteamID = obj.LenderSteamID,
					GameBorrowerSteamID = steamID
				};
			}

		}
예제 #23
0
		/// <summary>
		/// (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns basic profile information for a given 64-bit Steam ID.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return profile information for.</param>
		/// <returns>
		///	Returns profile data for the requested user in the form of a <see cref="Player"/> object. 
		/// Some data associated with a Steam account may be hidden if the user has their profile visibility set to "Friends Only" or "Private". In that case, only public data will be returned.
		/// </returns>
		public static SteamUser GetUser( SteamClient client, SteamID steamID ) {
			try {
				return GetUsersAsync( client, new SteamID[] { steamID } ).Result.FirstOrDefault();
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}
예제 #24
0
		/// <summary>
		/// (Requires Authentication) (Async) Returns a list of games a player has played in the last two weeks.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetRecentlyPlayedGames_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="maxSelect">Optionally limit response to a certain number of games. Defaults to -1, meaning no limit is imposed.</param>
		/// <returns><see cref="OwnedGames"/> object containing information about the specified user's game collection.</returns>
		public async static Task<PlayedGames> GetRecentlyPlayedGamesAsync( SteamClient client, string steamID, int maxSelect = -1 ) {

			SteamRequest request = new SteamRequest( SteamAPIInterface.IPlayerService, "GetRecentlyPlayedGames", SteamMethodVersion.v0001 );
			request.AddParameter( "steamid", steamID, ParameterType.QueryString );

			if( maxSelect > 0 ) 
				request.AddParameter( "count", maxSelect, ParameterType.QueryString );

			return VerifyAndDeserialize<GetRecentlyPlayedGamesResponse>( ( await client.ExecuteAsync( request ) ) ).PlayedGames;

		}
예제 #25
0
		/// <summary>
		/// (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Updates the PlayerInfo property for a given dictionary of SteamUsers.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="users">Users to update the profile information for.</param>
		/// <returns>Dictionary object containing the set of users with updated profile information.</returns>
		public async static Task<Dictionary<SteamID, SteamUser>> GetBulkProfileDataAsync( SteamClient client, Dictionary<SteamID, SteamUser> users ) {

			SteamID[] steamIDs = new SteamID[users.Count];
			steamIDs = users.Keys.ToArray();

			List<SteamUser> newUserData = await GetUsersAsync( client, steamIDs );

			foreach( var newUser in newUserData ) 
				users[newUser.SteamID].PlayerInfo = newUser.PlayerInfo;

			return users;

		}
예제 #26
0
		/// <summary>
		/// (Requires Authentication) Returns the original owner's SteamID if a borrowing account is currently playing the specified game. Null if not borrowed, or the borrower isn't currently playing the game.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// <a href="https://developer.valvesoftware.com/wiki/Steam_Web_API#IsPlayingSharedGame_.28v0001.29">See official documentation.</a>
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamID">SteamID to return friend's list for.</param>
		/// <param name="gameID">GameID (AppID) of the game you're interested in querying.</param>
		/// <returns></returns>
		public static SharedGameData IsPlayingSharedGame( SteamClient client, string steamID, int gameID ) {
			try {
				return IsPlayingSharedGameAsync( client, steamID, gameID ).Result;
			} catch( AggregateException e ) {
				if( e.InnerException != null )
					throw e.InnerException;
				throw e;
			}
		}