v1.0.0
Latest
2022.3+

Interface ILobbyService

Service for Lobbies. Provides user the ability to create, delete, update, and query Lobbies. Includes operations for interacting with given players in a Lobby context.

Namespace: Unity.Services.Lobbies
Syntax
public interface ILobbyService

Methods

CreateLobbyAsync(String, Int32, CreateLobbyOptions)

Create a Lobby with a given name and specified player limit. Async operation.

Declaration
Task<Lobby> CreateLobbyAsync(string lobbyName, int maxPlayers, CreateLobbyOptions options = null)
Parameters
TypeNameDescription
System.StringlobbyName

Name of new lobby.

System.Int32maxPlayers

Player limit.

CreateLobbyOptionsoptions

Optional request parameters.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data for the lobby that was just created.

Exceptions
TypeCondition
System.ArgumentNullException

Thrown when lobbyName is null or only contains whitespaces.

System.InvalidOperationException

Thrown when maxPlayers is less than one.

LobbyServiceException

Thrown when the lobby service returns an error.

CreateOrJoinLobbyAsync(String, String, Int32, CreateLobbyOptions)

Create or join a Lobby with a given name and ID and specified player limit. Async operation.

Declaration
Task<Lobby> CreateOrJoinLobbyAsync(string lobbyId, string lobbyName, int maxPlayers, CreateLobbyOptions options = null)
Parameters
TypeNameDescription
System.StringlobbyId

ID of the lobby to create/join.

System.StringlobbyName

Name of the lobby to create/join.

System.Int32maxPlayers

Player limit.

CreateLobbyOptionsoptions

Optional request parameters.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data for the lobby that was just created/joined.

Exceptions
TypeCondition
System.ArgumentNullException

Throw when lobbyId or lobbyName is empty or only contains whitespaces.

System.InvalidOperationException

Thrown when maxPlayers is less than one.

LobbyServiceException

Thrown when the lobby service returns an error.

DeleteLobbyAsync(String)

Delete a Lobby by specifying a Lobby ID. Async operation.

Declaration
Task DeleteLobbyAsync(string lobbyId)
Parameters
TypeNameDescription
System.StringlobbyId

ID of the Lobby to delete.

Returns
TypeDescription
System.Threading.Tasks.Task

Awaitable task.

Exceptions
TypeCondition
System.ArgumentNullException

Thrown when lobbyId is null or only contains whitespaces.

LobbyServiceException

Thrown when the lobby service returns an error.

GetJoinedLobbiesAsync()

Async Operation. Get currently joined lobbies.

Declaration
Task<List<string>> GetJoinedLobbiesAsync()
Returns
TypeDescription
System.Threading.Tasks.Task<System.Collections.Generic.List<System.String>>

List of lobbies the active player has joined.

Exceptions
TypeCondition
LobbyServiceException

Thrown when the lobby service returns an error.

GetLobbyAsync(String)

Retrieve data for a Lobby by specifying a Lobby ID. Async operation.

Declaration
Task<Lobby> GetLobbyAsync(string lobbyId)
Parameters
TypeNameDescription
System.StringlobbyId

ID of the Lobby to retrieve.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data.

Exceptions
TypeCondition
System.ArgumentNullException

Thrown when lobbyId is null or only contains whitespaces.

LobbyServiceException

Thrown when the lobby service returns an error.

JoinLobbyByCodeAsync(String, JoinLobbyByCodeOptions)

Join a Lobby using a given Lobby Invite Code. Async operation.

Declaration
Task<Lobby> JoinLobbyByCodeAsync(string lobbyCode, JoinLobbyByCodeOptions options = null)
Parameters
TypeNameDescription
System.StringlobbyCode

Invite Code for target lobby.

JoinLobbyByCodeOptionsoptions

Optional request parameters.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data for the lobby joined.

Exceptions
TypeCondition
System.ArgumentNullException

Thrown when lobbyCode is null or only contains whitespaces.

LobbyServiceException

Thrown when the lobby service returns an error.

JoinLobbyByIdAsync(String, JoinLobbyByIdOptions)

Join a Lobby by specifying the Lobby ID. Async operation.

Declaration
Task<Lobby> JoinLobbyByIdAsync(string lobbyId, JoinLobbyByIdOptions options = null)
Parameters
TypeNameDescription
System.StringlobbyId

ID of the Lobby to join.

JoinLobbyByIdOptionsoptions

Optional request parameters.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data for the lobby joined.

Exceptions
TypeCondition
System.ArgumentNullException

Thrown when lobbyId is null or only contains whitespaces.

LobbyServiceException

Thrown when the lobby service returns an error.

QueryLobbiesAsync(QueryLobbiesOptions)

Query and retrieve a list of lobbies that meet specified query parameters. Async operation.

Declaration
Task<QueryResponse> QueryLobbiesAsync(QueryLobbiesOptions options = null)
Parameters
TypeNameDescription
QueryLobbiesOptionsoptions

Query parameters.

Returns
TypeDescription
System.Threading.Tasks.Task<QueryResponse>

Query response that includes list of Lobbies meeting specified parameters.

Exceptions
TypeCondition
LobbyServiceException

Thrown when the lobby service returns an error.

QuickJoinLobbyAsync(QuickJoinLobbyOptions)

Query available lobbies and join a randomly selected instance. Async operation.

Declaration
Task<Lobby> QuickJoinLobbyAsync(QuickJoinLobbyOptions options = null)
Parameters
TypeNameDescription
QuickJoinLobbyOptionsoptions

Optional parameters (includes queryable arguments).

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data for the lobby joined.

Exceptions
TypeCondition
LobbyServiceException

Thrown when the lobby service returns an error.

ReconnectToLobbyAsync(String)

Reconnects to the lobby.

Declaration
Task<Lobby> ReconnectToLobbyAsync(string lobbyId)
Parameters
TypeNameDescription
System.StringlobbyId

The ID of the lobby to reconnect to.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

The lobby you reconnected to.

RemovePlayerAsync(String, String)

Remove a player from a specified Lobby. Async operation.

Declaration
Task RemovePlayerAsync(string lobbyId, string playerId)
Parameters
TypeNameDescription
System.StringlobbyId

Target Lobby ID to remove player from.

System.StringplayerId

Player ID to remove.

Returns
TypeDescription
System.Threading.Tasks.Task

Awaitable task.

Exceptions
TypeCondition
System.ArgumentNullException

Throw when lobbyId or playerId is empty or only contains whitespaces.

LobbyServiceException

Thrown when the lobby service returns an error.

SendHeartbeatPingAsync(String)

Send a heartbeat ping to keep the Lobby active. Async operation.

Declaration
Task SendHeartbeatPingAsync(string lobbyId)
Parameters
TypeNameDescription
System.StringlobbyId

ID of the Lobby to ping.

Returns
TypeDescription
System.Threading.Tasks.Task

Awaitable task.

Exceptions
TypeCondition
System.ArgumentNullException

Thrown when lobbyId is null or only contains whitespaces.

LobbyServiceException

Thrown when the lobby service returns an error.

SubscribeToLobbyEventsAsync(String, LobbyEventCallbacks)

A subscription to the given lobby is created and the given callbacks are associated with it. The return ILobbyEvents interface can be used to unsubscribe and re-subscribe to the connection. The callbacks object provided will be used to provide the notifications from the subscription.

Declaration
Task<ILobbyEvents> SubscribeToLobbyEventsAsync(string lobbyId, LobbyEventCallbacks callbacks)
Parameters
TypeNameDescription
System.StringlobbyId

The ID of the lobby you are subscribing to events for.

LobbyEventCallbackscallbacks

The callbacks you provide, which will be called as notifications arrive from the subscription.

Returns
TypeDescription
System.Threading.Tasks.Task<ILobbyEvents>

An interface to change the callbacks associated with the subscription, or to unsubscribe and re-subscribe to the lobby's events.

UpdateLobbyAsync(String, UpdateLobbyOptions)

Update the specified Lobby with the given option parameters. Async operation.

Declaration
Task<Lobby> UpdateLobbyAsync(string lobbyId, UpdateLobbyOptions options)
Parameters
TypeNameDescription
System.StringlobbyId

Lobby ID to update.

UpdateLobbyOptionsoptions

Parameters to update.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data of the updated Lobby.

Exceptions
TypeCondition
System.ArgumentNullException

Throw when lobbyId is null or only contains whitespaces or when options is null.

LobbyServiceException

Thrown when the lobby service returns an error.

UpdatePlayerAsync(String, String, UpdatePlayerOptions)

Update player lobby associated data with the given option parameters. Async operation.

Declaration
Task<Lobby> UpdatePlayerAsync(string lobbyId, string playerId, UpdatePlayerOptions options)
Parameters
TypeNameDescription
System.StringlobbyId

Lobby ID to update.

System.StringplayerId

Player ID to update.

UpdatePlayerOptionsoptions

Parameters to update.

Returns
TypeDescription
System.Threading.Tasks.Task<Lobby>

Lobby data of the updated Lobby

Exceptions
TypeCondition
System.ArgumentNullException

Throw when lobbyId or playerId is null or only contains whitespaces or when options is null.

LobbyServiceException

Thrown when the lobby service returns an error.