GetLobbySessionsAsync
method in Coherence.Cloud.LobbiesService
Methods
public Task<IReadOnlyList<LobbySession>> GetLobbySessionsAsync(CancellationToken cancellationToken = default)
Retrieves all lobby sessions that this player account is currently part of asynchronously.
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional parameter to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<IReadOnlyList<LobbySession>> | A task that represents the asynchronous operation. When the task completes successfully, it will contain a list of lobby sessions. |
Examples
using Coherence.Cloud;
using UnityEngine;
class GetLobbySessionsAsync : MonoBehaviour
{
async void Start()
{
PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();
var lobbyService = playerAccount.Services.Rooms.LobbyService;
var lobbySessions = await lobbyService.GetLobbySessionsAsync();
foreach (var lobbySession in lobbySessions)
{
Debug.Log($"Currently in lobby: {lobbySession.LobbyData.Name}");
}
}
}
Exceptions
| Type | Condition |
|---|---|
| TaskCanceledException | Thrown when the operation is canceled using the |
| ResponseDeserializationException | Thrown when the response from the server cannot be deserialized into a LobbySession. |