Class SteamMatchmaking
Purpose: Functions for match making services for clients to get to favorites and to operate on game lobbies.
Inherited Members
Namespace: Unity.Steamworks.Interop
Assembly: Unity.Steamworks.Interop.dll
Syntax
public static class SteamMatchmaking
Methods
AddFavoriteGame(AppId_t, uint, ushort, ushort, uint, uint)
adds the game server to the local list; updates the time played of the server if it already exists in the list
Declaration
public static int AddFavoriteGame(AppId_t nAppID, uint nIP, ushort nConnPort, ushort nQueryPort, uint unFlags, uint rTime32LastPlayedOnServer)
Parameters
| Type | Name | Description |
|---|---|---|
| AppId_t | nAppID | Passed through to |
| uint | nIP | Passed through to |
| ushort | nConnPort | Passed through to |
| ushort | nQueryPort | Passed through to |
| uint | unFlags | Passed through to |
| uint | rTime32LastPlayedOnServer | Passed through to |
Returns
| Type | Description |
|---|---|
| int | The value |
AddRequestLobbyListCompatibleMembersFilter(CSteamID)
Calls the Steamworks ISteamMatchmaking::AddRequestLobbyListCompatibleMembersFilter method.
Declaration
public static void AddRequestLobbyListCompatibleMembersFilter(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter)
sets the distance for which we should search for lobbies (based on users IP address to location map on the Steam backed)
Declaration
public static void AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter eLobbyDistanceFilter)
Parameters
| Type | Name | Description |
|---|---|---|
| ELobbyDistanceFilter | eLobbyDistanceFilter | Passed through to |
AddRequestLobbyListFilterSlotsAvailable(int)
returns only lobbies with the specified number of slots available
Declaration
public static void AddRequestLobbyListFilterSlotsAvailable(int nSlotsAvailable)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nSlotsAvailable | Passed through to |
AddRequestLobbyListNearValueFilter(string, int)
returns results closest to the specified value. Multiple near filters can be added, with early filters taking precedence
Declaration
public static void AddRequestLobbyListNearValueFilter(string pchKeyToMatch, int nValueToBeCloseTo)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pchKeyToMatch | Passed through to |
| int | nValueToBeCloseTo | Passed through to |
AddRequestLobbyListNumericalFilter(string, int, ELobbyComparison)
numerical comparison
Declaration
public static void AddRequestLobbyListNumericalFilter(string pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pchKeyToMatch | Passed through to |
| int | nValueToMatch | Passed through to |
| ELobbyComparison | eComparisonType | Passed through to |
AddRequestLobbyListResultCountFilter(int)
sets how many results to return, the lower the count the faster it is to download the lobby results & details to the client
Declaration
public static void AddRequestLobbyListResultCountFilter(int cMaxResults)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cMaxResults | Passed through to |
AddRequestLobbyListStringFilter(string, string, ELobbyComparison)
filters for lobbies this needs to be called before RequestLobbyList() to take effect these are cleared on each call to RequestLobbyList()
Declaration
public static void AddRequestLobbyListStringFilter(string pchKeyToMatch, string pchValueToMatch, ELobbyComparison eComparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pchKeyToMatch | Passed through to |
| string | pchValueToMatch | Passed through to |
| ELobbyComparison | eComparisonType | Passed through to |
CreateLobby(ELobbyType, int)
Create a lobby on the Steam servers. If private, then the lobby will not be returned by any RequestLobbyList() call; the CSteamID of the lobby will need to be communicated via game channels or via InviteUserToLobby() this is an asynchronous request results will be returned by LobbyCreated_t callback and call result; lobby is joined & ready to use at this point a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
Declaration
public static SteamAPICall_t CreateLobby(ELobbyType eLobbyType, int cMaxMembers)
Parameters
| Type | Name | Description |
|---|---|---|
| ELobbyType | eLobbyType | Passed through to |
| int | cMaxMembers | Passed through to |
Returns
| Type | Description |
|---|---|
| SteamAPICall_t | The value |
CreateLobbyAsync(ELobbyType, int)
Async version of CreateLobby(ELobbyType, int).
Declaration
public static Task<LobbyCreated_t> CreateLobbyAsync(ELobbyType eLobbyType, int cMaxMembers)
Parameters
| Type | Name | Description |
|---|---|---|
| ELobbyType | eLobbyType | Passed through to |
| int | cMaxMembers | Passed through to |
Returns
| Type | Description |
|---|---|
| Task<LobbyCreated_t> | The LobbyCreated_t Steam reports once the call completes. |
DeleteLobbyData(CSteamID, string)
removes a metadata key from the lobby
Declaration
public static bool DeleteLobbyData(CSteamID steamIDLobby, string pchKey)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| string | pchKey | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetFavoriteGame(int, out AppId_t, out uint, out ushort, out ushort, out uint, out uint)
returns the details of the game server iGame is of range [0,GetFavoriteGameCount()) *pnIP, *pnConnPort are filled in the with IP:port of the game server *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added
Declaration
public static bool GetFavoriteGame(int iGame, out AppId_t pnAppID, out uint pnIP, out ushort pnConnPort, out ushort pnQueryPort, out uint punFlags, out uint pRTime32LastPlayedOnServer)
Parameters
| Type | Name | Description |
|---|---|---|
| int | iGame | Passed through to |
| AppId_t | pnAppID | Passed through to |
| uint | pnIP | Passed through to |
| ushort | pnConnPort | Passed through to |
| ushort | pnQueryPort | Passed through to |
| uint | punFlags | Passed through to |
| uint | pRTime32LastPlayedOnServer | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetFavoriteGameCount()
game server favorites storage saves basic details about a multiplayer game server locally returns the number of favorites servers the user has stored
Declaration
public static int GetFavoriteGameCount()
Returns
| Type | Description |
|---|---|
| int | The value |
GetLobbyByIndex(int)
returns the CSteamID of a lobby, as retrieved by a RequestLobbyList call should only be called after a LobbyMatchList_t callback is received iLobby is of the range [0, LobbyMatchList_t::m_nLobbiesMatching) the returned CSteamID::IsValid() will be false if iLobby is out of range
Declaration
public static CSteamID GetLobbyByIndex(int iLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| int | iLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| CSteamID | The value |
GetLobbyChatEntry(CSteamID, int, out CSteamID, byte[], int, out EChatEntryType)
Get a chat message as specified in a LobbyChatMsg_t callback iChatID is the LobbyChatMsg_t::m_iChatID value in the callback *pSteamIDUser is filled in with the CSteamID of the member *pvData is filled in with the message itself return value is the number of bytes written into the buffer
Declaration
public static int GetLobbyChatEntry(CSteamID steamIDLobby, int iChatID, out CSteamID pSteamIDUser, byte[] pvData, int cubData, out EChatEntryType peChatEntryType)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| int | iChatID | Passed through to |
| CSteamID | pSteamIDUser | Passed through to |
| byte[] | pvData | Passed through to |
| int | cubData | Passed through to |
| EChatEntryType | peChatEntryType | Passed through to |
Returns
| Type | Description |
|---|---|
| int | The value |
GetLobbyData(CSteamID, string)
Get data associated with this lobby takes a simple key, and returns the string associated with it "" will be returned if no value is set, or if steamIDLobby is invalid
Declaration
public static string GetLobbyData(CSteamID steamIDLobby, string pchKey)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| string | pchKey | Passed through to |
Returns
| Type | Description |
|---|---|
| string | The value |
GetLobbyDataByIndex(CSteamID, int, out string, int, out string, int)
returns a lobby metadata key/values pair by index, of range [0, GetLobbyDataCount())
Declaration
public static bool GetLobbyDataByIndex(CSteamID steamIDLobby, int iLobbyData, out string pchKey, int cchKeyBufferSize, out string pchValue, int cchValueBufferSize)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| int | iLobbyData | Passed through to |
| string | pchKey | Receives the string |
| int | cchKeyBufferSize | Passed through to |
| string | pchValue | Receives the string |
| int | cchValueBufferSize | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetLobbyDataCount(CSteamID)
returns the number of metadata keys set on the specified lobby
Declaration
public static int GetLobbyDataCount(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| int | The value |
GetLobbyGameServer(CSteamID, out uint, out ushort, out CSteamID)
returns the details of a game server set in a lobby - returns false if there is no game server set, or that lobby doesn't exist
Declaration
public static bool GetLobbyGameServer(CSteamID steamIDLobby, out uint punGameServerIP, out ushort punGameServerPort, out CSteamID psteamIDGameServer)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| uint | punGameServerIP | Passed through to |
| ushort | punGameServerPort | Passed through to |
| CSteamID | psteamIDGameServer | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetLobbyMemberByIndex(CSteamID, int)
returns the CSteamID of a user in the lobby iMember is of range [0,GetNumLobbyMembers()) note that the current user must be in a lobby to retrieve CSteamIDs of other users in that lobby
Declaration
public static CSteamID GetLobbyMemberByIndex(CSteamID steamIDLobby, int iMember)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| int | iMember | Passed through to |
Returns
| Type | Description |
|---|---|
| CSteamID | The value |
GetLobbyMemberData(CSteamID, CSteamID, string)
Gets per-user metadata for someone in this lobby
Declaration
public static string GetLobbyMemberData(CSteamID steamIDLobby, CSteamID steamIDUser, string pchKey)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| CSteamID | steamIDUser | Passed through to |
| string | pchKey | Passed through to |
Returns
| Type | Description |
|---|---|
| string | The value |
GetLobbyMemberLimit(CSteamID)
returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined
Declaration
public static int GetLobbyMemberLimit(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| int | The value |
GetLobbyOwner(CSteamID)
returns the current lobby owner you must be a member of the lobby to access this there always one lobby owner - if the current owner leaves, another user will become the owner it is possible (bur rare) to join a lobby just as the owner is leaving, thus entering a lobby with self as the owner
Declaration
public static CSteamID GetLobbyOwner(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| CSteamID | The value |
GetNumLobbyMembers(CSteamID)
Lobby iteration, for viewing details of users in a lobby only accessible if the lobby user is a member of the specified lobby persona information for other lobby members (name, avatar, etc.) will be asynchronously received and accessible via ISteamFriends interface returns the number of users in the specified lobby
Declaration
public static int GetNumLobbyMembers(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| int | The value |
InviteUserToLobby(CSteamID, CSteamID)
Invite another user to the lobby the target user will receive a LobbyInvite_t callback will return true if the invite is successfully sent, whether or not the target responds returns false if the local user is not connected to the Steam servers if the other user clicks the join link, a GameLobbyJoinRequested_t will be posted if the user is in-game, or if the game isn't running yet the game will be launched with the parameter +connect_lobby <64-bit lobby id>
Declaration
public static bool InviteUserToLobby(CSteamID steamIDLobby, CSteamID steamIDInvitee)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| CSteamID | steamIDInvitee | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
JoinLobby(CSteamID)
Joins an existing lobby this is an asynchronous request results will be returned by LobbyEnter_t callback & call result, check m_EChatRoomEnterResponse to see if was successful lobby metadata is available to use immediately on this call completing
Declaration
public static SteamAPICall_t JoinLobby(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| SteamAPICall_t | The value |
JoinLobbyAsync(CSteamID)
Async version of JoinLobby(CSteamID).
Declaration
public static Task<LobbyEnter_t> JoinLobbyAsync(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| Task<LobbyEnter_t> | The LobbyEnter_t Steam reports once the call completes. |
LeaveLobby(CSteamID)
Leave a lobby; this will take effect immediately on the client side other users in the lobby will be notified by a LobbyChatUpdate_t callback
Declaration
public static void LeaveLobby(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
RemoveFavoriteGame(AppId_t, uint, ushort, ushort, uint)
removes the game server from the local storage; returns true if one was removed
Declaration
public static bool RemoveFavoriteGame(AppId_t nAppID, uint nIP, ushort nConnPort, ushort nQueryPort, uint unFlags)
Parameters
| Type | Name | Description |
|---|---|---|
| AppId_t | nAppID | Passed through to |
| uint | nIP | Passed through to |
| ushort | nConnPort | Passed through to |
| ushort | nQueryPort | Passed through to |
| uint | unFlags | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
RequestLobbyData(CSteamID)
Refreshes metadata for a lobby you're not necessarily in right now you never do this for lobbies you're a member of, only if your this will send down all the metadata associated with a lobby this is an asynchronous call returns false if the local user is not connected to the Steam servers results will be returned by a LobbyDataUpdate_t callback if the specified lobby doesn't exist, LobbyDataUpdate_t::m_bSuccess will be set to false
Declaration
public static bool RequestLobbyData(CSteamID steamIDLobby)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
RequestLobbyList()
Game lobby functions Get a list of relevant lobbies this is an asynchronous request results will be returned by LobbyMatchList_t callback & call result, with the number of lobbies found this will never return lobbies that are full to add more filter, the filter calls below need to be call before each and every RequestLobbyList() call use the CCallResult<> object in steam_api.h to match the SteamAPICall_t call result to a function in an object, e.g. class CMyLobbyListManager { CCallResult<CMyLobbyListManager, LobbyMatchList_t> m_CallResultLobbyMatchList; void FindLobbies() { SteamMatchmaking()->AddRequestLobbyListFilter*() functions would be called here, before RequestLobbyList() SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList(); m_CallResultLobbyMatchList.Set( hSteamAPICall, this, &CMyLobbyListManager::OnLobbyMatchList ); } void OnLobbyMatchList( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure ) { lobby list has be retrieved from Steam back-end, use results } }
Declaration
public static SteamAPICall_t RequestLobbyList()
Returns
| Type | Description |
|---|---|
| SteamAPICall_t | The value |
RequestLobbyListAsync()
Async version of RequestLobbyList().
Declaration
public static Task<LobbyMatchList_t> RequestLobbyListAsync()
Returns
| Type | Description |
|---|---|
| Task<LobbyMatchList_t> | The LobbyMatchList_t Steam reports once the call completes. |
SendLobbyChatMsg(CSteamID, byte[], int)
Broadcasts a chat message to the all the users in the lobby users in the lobby (including the local user) will receive a LobbyChatMsg_t callback returns true if the message is successfully sent pvMsgBody can be binary or text data, up to 4k if pvMsgBody is text, cubMsgBody should be strlen( text ) + 1, to include the null terminator
Declaration
public static bool SendLobbyChatMsg(CSteamID steamIDLobby, byte[] pvMsgBody, int cubMsgBody)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| byte[] | pvMsgBody | Passed through to |
| int | cubMsgBody | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
SetLinkedLobby(CSteamID, CSteamID)
link two lobbies for the purposes of checking player compatibility you must be the lobby owner of both lobbies
Declaration
public static bool SetLinkedLobby(CSteamID steamIDLobby, CSteamID steamIDLobbyDependent)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| CSteamID | steamIDLobbyDependent | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
SetLobbyData(CSteamID, string, string)
Sets a key/value pair in the lobby metadata each user in the lobby will be broadcast this new value, and any new users joining will receive any existing data this can be used to set lobby names, map, etc. to reset a key, just set it to "" other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback
Declaration
public static bool SetLobbyData(CSteamID steamIDLobby, string pchKey, string pchValue)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| string | pchKey | Passed through to |
| string | pchValue | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
SetLobbyGameServer(CSteamID, uint, ushort, CSteamID)
sets the game server associated with the lobby usually at this point, the users will join the specified game server either the IP/Port or the steamID of the game server has to be valid, depending on how you want the clients to be able to connect
Declaration
public static void SetLobbyGameServer(CSteamID steamIDLobby, uint unGameServerIP, ushort unGameServerPort, CSteamID steamIDGameServer)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| uint | unGameServerIP | Passed through to |
| ushort | unGameServerPort | Passed through to |
| CSteamID | steamIDGameServer | Passed through to |
SetLobbyJoinable(CSteamID, bool)
sets whether or not a lobby is joinable - defaults to true for a new lobby if set to false, no user can join, even if they are a friend or have been invited
Declaration
public static bool SetLobbyJoinable(CSteamID steamIDLobby, bool bLobbyJoinable)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| bool | bLobbyJoinable | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
SetLobbyMemberData(CSteamID, string, string)
Sets per-user metadata (for the local user implicitly)
Declaration
public static void SetLobbyMemberData(CSteamID steamIDLobby, string pchKey, string pchValue)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| string | pchKey | Passed through to |
| string | pchValue | Passed through to |
SetLobbyMemberLimit(CSteamID, int)
set the limit on the # of users who can join the lobby
Declaration
public static bool SetLobbyMemberLimit(CSteamID steamIDLobby, int cMaxMembers)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| int | cMaxMembers | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
SetLobbyOwner(CSteamID, CSteamID)
changes who the lobby owner is you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby after completion, the local user will no longer be the owner
Declaration
public static bool SetLobbyOwner(CSteamID steamIDLobby, CSteamID steamIDNewOwner)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| CSteamID | steamIDNewOwner | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
SetLobbyType(CSteamID, ELobbyType)
updates which type of lobby it is only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable, will be returned by RequestLobbyList() calls
Declaration
public static bool SetLobbyType(CSteamID steamIDLobby, ELobbyType eLobbyType)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamIDLobby | Passed through to |
| ELobbyType | eLobbyType | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |