Matchmaking.Client
Unity centric wrapper around the ISteamMatchmaking API
Like what your seeing?
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!
Introduction
The whole of the matchmaking system is only accessible from the Client API as a result you will always be using the form:
TIP
Save your self some typing. add this using statement to the top of any script that will need to use this API.
You can now access members in this API with a shorter call structure
as opposed to the long form:
What can it do?
The matchmaking system is fundamentally a system for getting player's together in order to play games. The main feature of the system is the Steam Lobby. Steam Lobbies can be searched for based on the metadata of a lobby, they can be advertised via Party Beacons, on the friends list and direct invites can be sent to targeted players.
Steam Lobby can be used for more than a simple game lobby, depending on your games specific needs they can provide for teams, party/groups, session merging and more. Valve allows a user to be a member of 1 "normal" lobby and up to 2 additional "invisible" lobbies. Each lobby has its own set of metadata for the lobby its self and for each of its members and each lobby includes a simple chat system.
Take a look at the Lobby Manager for a tool that can help you manage a specific uses for a Steam Lobby and which can simplify lobby interactions and facilitate lobby UIs.
Related Components
Related Objects
Events
EventLobbyEnterSuccess
Occurs when a lobby enter callback is received and the response code is a success
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyEnterFailed
Occurs when a lobby enter callback is received and the response code is not a success.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyDataUpdate
Occurs when the lobby metadata has changed.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyChatMsg
Occurs when a chat (text or binary) message for this lobby has been received. After getting this you must use GetLobbyChatEntry to retrieve the contents of this message.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventFavoritesListChanged
A server was added/removed from the favorites list, you should refresh now.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behviour using it is destroyed
EventLobbyChatUpdate
A lobby chat room state has changed, this is usually sent when a user has joined or left the lobby.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyGameCreated
A game server has been set via Set Lobby Game Server for all of the members of the lobby to join. It's up to the individual clients to take action on this; the typical game behavior is to leave the lobby and connect to the specified game server; but the lobby may stay open throughout the session if desired.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyInvite
Someone has invited you to join a Lobby. Normally you don't need to do anything with this, as the Steam UI will also display a '<user> has invited you to the lobby, join?' notification and message.
If the user outside a game chooses to join, your game will be launched with the parameter +connect_lobby <64-bit lobby id>
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyLeave
Invoked when API.Matchmaking.Client.LeaveLobby is called
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
EventLobbyAskedToLeave
The local user has been asked to leave a lobby. In general you should handle this event and leave when asked assuming your game has implemented kick lobby.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behavior using it is destroyed
Fields and Attributes
MemberOfLobbies
This list is populated by the system as the user creates, joins and leaves lobbies. It is a list of lobbies the user is currently a member of.
You can call this field via
Methods
AddHistoryGame
Adds the game server to the local favorites list or updates the time played of the server if it already exists in the list.
AddFavoriteGame
Adds the game server to the local favorites list or updates the time played of the server if it already exists in the list.
AddHistoryGame
Adds the game server to the local favorites list or updates the time played of the server if it already exists in the list.
AddFavoriteGame
Adds the game server to the local favorites list or updates the time played of the server if it already exists in the list.
AddRequestLobbyListDistanceFilter
Sets the physical distance for which we should search for lobbies, this is based on the users IP address and a IP location map on the Steam backed.
AddRequestLobbyListFilterSlotsAvailable
Filters to only return lobbies with the specified number of open slots available.
AddRequestLobbyListNearValueFilter
Sorts the results closest to the specified value.
Near filters don't actually filter out values, they just influence how the results are sorted. You can specify multiple near filters, with the first near filter influencing the most, and the last near filter influencing the least.
AddRequestLobbyListNumericalFilter
Adds a numerical comparison filter to the next RequestLobbyList call.
AddRequestLobbyListResultCountFilter
Sets the maximum number of lobbies to return. The lower the count the faster it is to download the lobby results & details to the client.
AddRequestLobbyListStringFilter
Adds a string comparison filter to the next RequestLobbyList call.
CreateLobby
The callback delegate should be in the form of
Create a new lobby and set the max members allowed. The callback will report success or failure and the reason why via the EResult value.
DeleteLobbyData
Removes a metadata key from the lobby.
GetFavoriteGame
Gets the details of the favorite game server by index.
GetFavoriteGames
Returns the collection of favorite game entries
GetFavoriteGameCount
Gets the number of favorite and recent game servers the user has stored locally.
GetLobbyData
Gets the metadata associated with the specified key from the specified lobby.
GetLobbyGameServer
Gets the details of a game server set in a lobby.
GetLobbyMembers
The current user must be in the lobby to retrieve the Steam IDs of other users in that lobby.
Returns a list of user IDs for the members of the indicated lobby
GetLobbyMemberLimit
The current limit on the # of users who can join the lobby.
GetLobbyOwner
Returns the current lobby owner.
InviteUserToLobby
Invite another user to the lobby.
JoinLobby
Joins an existing lobby.
LeaveLobby
Leave a lobby that the user is currently in; this will take effect immediately on the client side, other users in the lobby will be notified by a LobbyChatUpdate_t callback.
RemoveFavoriteGame
Removes the game server from the local favorites list.
RemoveHistoryGame
Removes the game server from the local history list.
RequestLobbyData
If your in the lobby then its data is always up to date
Refreshes all of the metadata for a lobby that you're not in right now.
RequestLobbyList
Get a filtered list of relevant lobbies.
There can only be one active lobby search at a time. The old request will be canceled if a new one is started. Depending on the users connection to the Steam back-end, this call can take from 300ms to 5 seconds to complete, and has a timeout of 20 seconds.
To filter the results you MUST call the AddRequestLobbyList* functions before calling this. The filters are cleared on each call to this function.
If AddRequestLobbyListDistanceFilter is not called, k_ELobbyDistanceFilterDefault will be used, which will only find matches in the same or nearby regions.
This will only return lobbies that are not full, and only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable with SetLobbyJoinable.
SendLobbyChatMsg
Broadcasts a chat (text or binary data) message to the all of the users in the lobby.
SetLobbyData
This can only be set by the owner of the lobby. Lobby members should use SetLobbyMemberData instead.
Sets a key/value pair in the lobby metadata. This can be used to set the the lobby name, current map, game mode, etc.
SetLobbyGameServer
Sets the game server associated with the lobby.
This can only be set by the owner of the lobby.
Either the IP/Port or the Steam ID of the game server must be valid, depending on how you want the clients to be able to connect.
A LobbyGameCreated_t callback will be sent to all players in the lobby, usually at this point, the users will join the specified game server.
SetLobbyJoinable
Sets whether or not a lobby is joinable by other players. This always defaults to enabled for a new lobby.
If joining is disabled, then no players can join, even if they are a friend or have been invited.
GetLobbyMemberData
Gets per-user metadata from another player in the specified lobby.
GetMember
Get the LobbyMember object for a given user
IsAMember
Checks if a user is a member of this lobby
SetLobbyMemberData
Sets per-user metadata for the local user.
Each user in the lobby will be receive notification of the lobby data change via a LobbyDataUpdate_t callback, and any new users joining will receive any existing data.
SetLobbyMemberLimit
Set the maximum number of players that can join the lobby.
SetLobbyOwner
Changes who the lobby owner is.
This can only be set by the owner of the lobby. This will trigger a LobbyDataUpdate_t for all of the users in the lobby, each user should update their local state to reflect the new owner. This is typically accomplished by displaying a crown icon next to the owners name.
SetLobbyType
Updates what type of lobby this is.
CancelQuery
Cancel an outstanding server list request.
CancelServerQuery
Cancel an outstanding individual server query.