How to keep lobby code active after the lobby is empty?

Hello,

I’m making a game using lobby and relay that the player can create and enter in rooms. The player can enter the room automatically, so there is no need to wait others players to join or wait the host to allow joining a room.

Each room is a lobby, and the players are connected using relay. I notice when everyone leaves a lobby after some seconds this lobby is deleted with its lobby code. This behavior occurs when the game is closed too.

I would like to keep the lobby code alive to rejoin a lobby or create another lobby with this former lobby code. How can I do this?

I don’t think there’s an exact match for what you’re asking for, but there are 2 related options you might consider:

  • If you create/manage a lobby using a service account, when the last player leaves and the lobby becomes empty, it will not be deleted like it would be in a player-managed lobby. You could use this in tandem with some mechanism for heartbeating the lobby to keep it active (and thus prevent deletion by the Lobby service itself) in between games.
  • If it would be acceptable to maintain a consistent lobby ID instead of code, you could use the Create Or Join API to keep the same lobby reference from game to game.

Thanks for the answer!

I guess I can replace the lobby code for the lobby ID, I did a simple test: I joined 2 lobbies, after that quit my game and play it again and l verified my joined lobbies using LobbyService.Instance.GetJoinedLobbiesAsync();

My question is for how long seconds or minutes the lobby ID will be saved?