It is not recommended to use FindLobbies to implement background matchmaking. We highly recommend using the matchmaking feature in that scenario. Otherwise you must handle the collisions of players all trying to join the same lobbies through filtering, sorting, and other techniques such as using randomization values in your search data fields.
Understanding the relationship between lobby search properties and finding lobbies
Players make their lobbies discoverable by defining search properties. Players find these discoverable lobbies by calling FindLobbies with query strings to filter and sort their search results based on the search properties defined across the currently active lobbies. Lobbies that match these queries are returned to the calling player. For more information on defining search properties, checkout Creating searchable lobbiesHow to use FindLobbies
When calling FindLobbies, you can use the filter parameter to restrict your query to only return search results matching some set of criteria based on the lobby’s custom search properties. Additionally, you can use the sorting parameter to sort the results you get back from the service based on the search properties. This is useful since the service only returns a limited number of search results. Sorting ensures you see the most relevant search results.Common Scenarios
Here are a few common ways the FindLobbies functionality is used in titles.- Finding lobbies for game sessions for a specific game mode in your title
- Finding lobbies for game sessions your friends are hosting
- Finding lobbies for game sessions with enough players for all local players
- Finding lobbies you’re already in to recover a connection after an unexpected game client or game server crash.
Supported search keys
Only a restricted set of keys are allowed to be used when defining custom search properties.- For string properties, the following keys are supported: string_key1, string_key2, […] string_key30
- For numeric properties, the following keys are supported: number_key1, number_key2, […] number_key30
Constructing query strings for FindLobbies
Query strings for the FindLobbies APIs are structured in an OData-like syntax. The maximum size for the filter string is 600 characters. These OData operators can be used to compose query strings. The operators are case sensitive.When comparing string properties, be sure to wrap the compared value in single quotes. For example, “string_key1 eq ‘SOME STRING VALUE’”. Numeric properties don’t need to be wrapped.
The SDK definition for these constants is documented here.
Sorting
OData style string that contains sorting for this query in either ascending (“asc”) or descending (“desc”) order. OrderBy clauses can be used for any of the search number keys or the predefined search keys that are numeric. To sort by closest to a number, a moniker distance can be used to sort by distance from the given number search key. You cannot use ascending or descending with the distance sort. This field only supports either one sort clause or one distance clause. If no sort is provided or if a tiebreak is needed for the given sort, the default sort would be descending based on creation time.Example finding lobbies using the Lobby and Matchmaking SDK
In this example, the player wants to find all lobbies with the following requirements:- The game-mode is “DeathMatch”
- The competition style is “Ranked”
- The player’s skill level is within the lobby’s minimum and maximum skill limits.
- Lobbies with optimal skill levels closest to the player’s skill level should sort higher
