Skip to main content

Implementing Continuous Lobbies

setting up a join-in-progress lobby

Jason Liang avatar
Written by Jason Liang
Updated over a week ago

You may want to implement continuous lobbies to better support your game's flow in the following situations:

  1. Allowing players to join a game already in progress, even after the game instance has been launched.

  2. Enabling players to return to the same lobby after the game instance has ended.

Essential steps to implement a continuous lobby:

  1. Create a lobby type with Allow join in progress option enabled

  2. Call FindOrCreateLobby method with the lobbyType created above from your client code, similar to this:

    void OnRTTEnabled(string jsonResponse, object cbObject)
    {
    var algo = new Dictionary<string, object>();
    algo["strategy"] = "ranged-absolute";
    algo["alignment"] = "center";
    List<int> ranges = new List<int>();
    ranges.Add(1000);
    algo["ranges"] = ranges;
    _bc.LobbyService.FindOrCreateLobby(
    "CustomGame",
    0,
    1,
    algo,
    new Dictionary<string, object>(),
    true,
    new Dictionary<string, object>(),
    "all",
    new Dictionary<string, object>(),
    null,
    null,
    OnFailed,
    null
    );
    }

  3. Done! Lobby members will continue receiving RTT event updates when new players join the game.

  4. If you're running a custom room server, call the SysRoomStopped method from the server via S2S API. This will stop the game server, return players to the lobby, and reset the lobby to its initial setup state.

Note that the default lifespan for the long-lived lobby is 1 hour. Suppose a server instance gets launched associated with the long-lived lobby AND it continues to report back to brainCloud via the SysRoomKeepAlive call. In that case, the drop-dead timeout for the lobby instance will continue to be pushed out indefinitely, at least until it reaches the maximum allowed server instance run time.

Did this answer your question?