예제 #1
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;

		}