Class LobbyApi
Represents a collection of functions to interact with the API endpoints
Inherited Members
Namespace: Unity.Services.Apis.Lobbies
Assembly: Unity.Services.Apis.dll
Syntax
public class LobbyApi : ILobbyApi, IApiAccessor
Constructors
LobbyApi(IApiClient)
Initializes a new instance of the Lobby
Declaration
public LobbyApi(IApiClient apiClient)
Parameters
Type | Name | Description |
---|---|---|
IApi |
apiClient | The client interface for synchronous API access. |
LobbyApi(IApiClient, IApiConfiguration)
Initializes a new instance of the Lobby
Declaration
public LobbyApi(IApiClient apiClient, IApiConfiguration apiConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IApi |
apiClient | The client interface for synchronous API access. |
IApi |
apiConfiguration | The configuration object. |
Properties
Client
The client for accessing this underlying API asynchronously.
Declaration
public IApiClient Client { get; }
Property Value
Type | Description |
---|---|
IApi |
Configuration
Gets the configuration object
Declaration
public IApiConfiguration Configuration { get; }
Property Value
Type | Description |
---|---|
IApi |
An instance of the Configuration |
Methods
BulkUpdateLobby(string, string, string, BulkUpdateRequest, CancellationToken)
Bulk update Apply a bulk update to a lobby. This can modify the lobby's metadata, add players, update players, and remove players. This operation is only allowed for service accounts.
Declaration
public ApiOperation<Lobby> BulkUpdateLobby(string lobbyId, string serviceId = null, string impersonatedUserId = null, BulkUpdateRequest bulkUpdateRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Bulk |
bulkUpdateRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
CreateLobby(string, string, CreateRequest, CancellationToken)
Create a lobby Create a new lobby and return the lobby metadata.
Declaration
public ApiOperation<Lobby> CreateLobby(string serviceId = null, string impersonatedUserId = null, CreateRequest createRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Create |
createRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
CreateOrJoinLobby(string, string, string, CreateRequest, CancellationToken)
Create or join a lobby with lobby ID CreateOrJoin will attempt to create a lobby with a specific ID. If a Lobby with that ID already exists, we will attempt to join the Lobby. Joining the Lobby may fail the same way as the regular Join Lobby call (e.g. lobby is full, lobby is password protected) and may even fail with Not Found if the Lobby happens to get deleted part way through the request. You should handle these failures the same way you would handle any Lobby join failure.
Declaration
public ApiOperation<Lobby> CreateOrJoinLobby(string lobbyId, string serviceId = null, string impersonatedUserId = null, CreateRequest createRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Create |
createRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
DeleteLobby(string, string, string, CancellationToken)
Delete a lobby Delete a lobby so it's no longer discoverable/joinable.
Declaration
public ApiOperation DeleteLobby(string lobbyId, string serviceId = null, string impersonatedUserId = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
GetBasePath()
Gets the base path of the API client.
Declaration
public string GetBasePath()
Returns
Type | Description |
---|---|
string | The base path |
GetHostedLobbies(string, string, CancellationToken)
Get a player/service's hosted lobbies Get a list of lobby IDs that are currently hosted by the player/service.
Declaration
public ApiOperation<List<string>> GetHostedLobbies(string serviceId = null, string impersonatedUserId = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
GetJoinedLobbies(string, string, CancellationToken)
Get a player's joined lobbies Get a list of lobby IDs that the player is currently a member of.
Declaration
public ApiOperation<List<string>> GetJoinedLobbies(string serviceId = null, string impersonatedUserId = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
GetLobby(string, string, string, string, CancellationToken)
Get lobby details Get the full details for a lobby including the game-specific metadata and player details.
Declaration
public ApiOperation<Lobby> GetLobby(string lobbyId, string serviceId = null, string impersonatedUserId = null, string ifNoneMatch = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
string | ifNoneMatch | The etag of the record being requested. Results/actions are only returned/executed when the current record version does not match the provided value. (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
Heartbeat(string, string, string, object, CancellationToken)
Heartbeat a lobby Heartbeat a lobby, updating its LastUpdated
property, to signify that the lobby is not stale.
Declaration
public ApiOperation Heartbeat(string lobbyId, string serviceId = null, string impersonatedUserId = null, object body = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
object | body | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
JoinLobbyByCode(string, string, JoinByCodeRequest, CancellationToken)
Join a lobby with lobby code Join an existing lobby using the lobby code if there is space available (i.e. total number of players is less than the value of MaxPlayers
).
Declaration
public ApiOperation<Lobby> JoinLobbyByCode(string serviceId = null, string impersonatedUserId = null, JoinByCodeRequest joinByCodeRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Join |
joinByCodeRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
JoinLobbyById(string, string, string, JoinByIdRequest, CancellationToken)
Join a lobby with lobby ID Join an existing lobby using the lobby ID if there is space available (i.e. total number of players is less than the value of MaxPlayers
).
Declaration
public ApiOperation<Lobby> JoinLobbyById(string lobbyId, string serviceId = null, string impersonatedUserId = null, JoinByIdRequest joinByIdRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Join |
joinByIdRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
QueryLobbies(string, string, QueryRequest, CancellationToken)
Query public lobbies Query all of the public lobbies for a title and filter them down according to parameters provided by the client.
Declaration
public ApiOperation<QueryResponse> QueryLobbies(string serviceId = null, string impersonatedUserId = null, QueryRequest queryRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Query |
queryRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
QuickJoinLobby(string, string, QuickJoinRequest, CancellationToken)
Query available lobbies and join a random one Query all of the available lobbies for a title and filter them down according to parameters provided by the client. If possible, join one and return its information.
Declaration
public ApiOperation<Lobby> QuickJoinLobby(string serviceId = null, string impersonatedUserId = null, QuickJoinRequest quickJoinRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Quick |
quickJoinRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
Reconnect(string, string, string, object, CancellationToken)
Reconnect to a lobby after disconnecting Reconnect a disconnected player to a lobby using the lobby ID. A disconnected player remains in the lobby but must reconnect in order to avoid being automatically removed after a configurable period of time. The duration can be set by the developer in the Lobby service configuration.
Declaration
public ApiOperation<Lobby> Reconnect(string lobbyId, string serviceId = null, string impersonatedUserId = null, object body = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
object | body | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
RemovePlayer(string, string, string, string, CancellationToken)
Remove a player Remove an individual player from a lobby. If the player being removed is the host, a random player is chosen as the new host. Hosts can avoid this by changing the hostId
to another player using the Update Lobby API before leaving.
Declaration
public ApiOperation RemovePlayer(string lobbyId, string playerId, string serviceId = null, string impersonatedUserId = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | playerId | The ID of the player to execute the request against. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
UpdateLobby(string, string, string, UpdateRequest, CancellationToken)
Update lobby data Update the properties of a lobby. This could include the lobby name, number of max players, the lobby's data
property, etc.
Declaration
public ApiOperation<Lobby> UpdateLobby(string lobbyId, string serviceId = null, string impersonatedUserId = null, UpdateRequest updateRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Update |
updateRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |
UpdatePlayer(string, string, string, string, PlayerUpdateRequest, CancellationToken)
Update player data Update the properties of a player. Only the player matching the player ID can perform this action. This could include updating the data
property for an individual player to include game-specific metadata. The index data property is not allowed on player data objects at this time.
Declaration
public ApiOperation<Lobby> UpdatePlayer(string lobbyId, string playerId, string serviceId = null, string impersonatedUserId = null, PlayerUpdateRequest playerUpdateRequest = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | lobbyId | The ID of the lobby to execute the request against. It should be composed of 64 characters or less, and only have dashes, underscores and alphanumeric characters. |
string | playerId | The ID of the player to execute the request against. |
string | serviceId | When service authentication is used, this provides a logical identity for the service (optional) |
string | impersonatedUserId | When service authentication is used, this provides a 'playerId' to execute as. If this header is detected, the service request will be identical to a request from the specified player. (optional) |
Player |
playerUpdateRequest | (optional) |
Cancellation |
cancellationToken | Cancellation Token to cancel the request. |
Returns
Type | Description |
---|---|
Api |
The operation |