Merge pull request #277 from thesupersoup/master

LobbyQuery FilterStringKeyValue method
This commit is contained in:
Garry Newman 2019-06-24 13:35:59 +01:00 committed by GitHub
commit 57f3b334b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -12,6 +12,12 @@ namespace Steamworks
/// </summary>
public static class SteamMatchmaking
{
/// <summary>
/// Maximum number of characters a lobby metadata key can be
/// </summary>
internal static int MaxLobbyKeyLength => 255;
static ISteamMatchmaking _internal;
internal static ISteamMatchmaking Internal
@ -37,7 +43,7 @@ internal static void InstallEvents()
{
LobbyInvite_t.Install( x => OnLobbyInvite?.Invoke( new Friend( x.SteamIDUser ), new Lobby( x.SteamIDLobby ) ) );
LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby(x.SteamIDLobby ) ) );
LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby( x.SteamIDLobby ) ) );
LobbyDataUpdate_t.Install( x =>
{

View File

@ -43,6 +43,30 @@ public LobbyQuery FilterDistanceWorldwide()
}
#endregion
#region String key/value filter
internal MatchMakingKeyValuePair_t? stringFilter;
/// <summary>
/// Filter by specified key/value pair; string parameters
/// </summary>
public LobbyQuery FilterStringKeyValue( string nKey, string nValue )
{
if ( string.IsNullOrEmpty( nKey ) )
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( nKey ) );
if ( nKey.Length > SteamMatchmaking.MaxLobbyKeyLength )
throw new System.ArgumentException( "Key length is longer than MaxLobbyKeyLength", nameof( nKey ) );
stringFilter = new MatchMakingKeyValuePair_t
{
Key = nKey,
Value = nValue
};
return this;
}
#endregion
#region Slots Filter
internal int? slotsAvailable;
@ -88,6 +112,11 @@ void ApplyFilters()
{
SteamMatchmaking.Internal.AddRequestLobbyListResultCountFilter( maxResults.Value );
}
if( stringFilter.HasValue )
{
SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( stringFilter.Value.Key, stringFilter.Value.Value, LobbyComparison.Equal );
}
}
/// <summary>