Poll for updates

The Lobby service enables players to find and connect with other players. It provides a lightweight, non-realtime way to share data and jump into scenarios that best fit the player’s needs without requiring a dedicated game server. Players can also use this to establish a real-time connection with each other (for example, by using the Relay service).

The data in a lobby can change and might occasionally need to be polled. The following list details example scenarios where polling might be required:

  • A player’s real-time Lobby updates arrived out-of-order and the most recent lobby needs to be reloaded
  • Connection info (how to establish a real-time connection) isn’t populated yet
  • The real-time connection is lost and new connection info is required (for example, finding out if the host has changed or if the connection information has changed)
  • When storing and retrieving not frequently updated data about the player

It’s important that you ensure that polling is not used to mimic real-time data passing. In general, real-time events should be used for that purpose (see Using Events). The Lobby service uses rate limiting, and attempts to misuse Lobby’s APIs can lead to getting throttled. See Rate limits.

The following code sample shows how to get a lobby:

C#

try
{
    var lobby = await LobbyService.Instance.GetLobbyAsync("lobbyId");
}
catch (LobbyServiceException e)
{
    Debug.Log(e);
}