Lobby & player management. Create & join lobbies instantly.
The lobbies module is a casual matchmaker optimized to get your player connected to your game server in under a second in the optimal region & lobby.
Supports multiple backends, including:
To integrate your servers to the Lobbies system, you need to call these three scripts in your server code.
set_lobby_ready
: Notifies the lobbies system that the server is ready to accept playersset_player_connected
: Notifies the lobbies system of a player connection while confirming the connection’s legitimacyset_player_disconnected
: Notifies the lobbies system of a player disconnectionAnd don’t worry about notifying the lobbies system if your lobby closes or crashes, that gets taken internally by the Dynamic Server system. Although if you want to manually tell the lobbies system to stop letting in new players, you can call the lobbies.setClosed
endpoint.
Once integrated, you can call the following scripts to find and join available lobbies in your client code.
find
: Finds an available lobby and grants a player token to connectjoin
: Given a lobby’s id, grants a player token to be used for connectionIf you want the client to be able to create a whole new lobby (for things like private games), you can also use the create
script.
Additionally, you can make use of these scripts to get more information about your game’s lobbies.
list_regions
: Returns listing of all regions available in gamelist
: Returns listing of all the lobbies linked to the lobbies systemlobbies.players.getStatistics
: Returns player count statistics by region and game modeThe Lobbies system is tightly integrated with Dynamic Servers to automatically boot lobbies on-demand when players need them. Read more about how Dynamic Servers operates your game servers here.
This document explains the logic going on behind the scenes when a game calls find.
Lobbies will return the lobby in the closest region with the least spots available (i.e. max players - current players
).
If no region is specified in find, OpenGB will use the GeoIP location provided by Cloudflare to find the nearest datacenter.
GeoIP does not always provide the most optimal route to the datacenter, so we recommend providing the user with the ability to select their own region.
Once the region has been determined, Lobbies will filter out full lobbies and then find the fullest lobby (i.e. least available spots).
find allows the developer to provide multiple game modes to join. In this case, Lobbies will select the optimal lobby from all of the provided game modes.
This can be helpful for games with low traffic but still want to provide multiple game modes to their users. In this situation, new players will be connected to any lobby for any game mode with players in it.
When all of the lobbies are full or there are no lobbies running, Lobbies will automatically create a new lobby for the game mode specified and connect the player to that lobby.
If this is not the desired behavior, find can be called with prevent_auto_create_lobby
as true
. This will return a MATCHMAKER_NO_AVAILABLE_LOBBIES error when no lobby can accept players.
Player counts in a given region usually fluxuate by at least 50% ever day during off hours. Games often feel more empty than they actually are as players are leaving the game because there are more lobbies with less players spread evenly across them.
For example:
Even though there are twice as many players online at 10 PM as there were at 9 AM, there are less players in each lobby.
Lobbies is designed to mitigate this issue by prioritizing filling a few lobbies instead of spreading players across all lobbies.
Take our example at 10 PM where there are 5 lobbies with 2 players in each lobby. If 2 new players come online, they will all be put in the same lobby, so one of the lobbies will have 4 players in it while the rest still have 2 players in them..
In our example, we still have 4 lobbies with only 2 players online.
We recommend prompting players to find a new lobby when the lobby is almost empty. By having the players in these empty lobbies call find_or_create
again, the players will be compacted in fewer, fuller lobbies.
The OpenGB uses the client’s IP address to determine the closest region. This allows us to find the optimal lobby for the player and connect them to a lobby in under a second.
If you want to implement your own region selection logic, use list_regions
to list all enabled regions for your game.
We use Cloudflare’s provided geolocation.
There are a series of existing GeoIP databases with varying accuracy that we researched. However, we found that Cloudflare provides the most consistently accurate client location since they have more routing information than just the client’s IP to work with.
The following environment variables are automatically set for each lobby:
LOBBY_ID
A unique identifier for the lobby. This is a UUID string.LOBBY_VERSION
The version of the lobby, as specified in the lobby configuration.LOBBY_TOKEN
A secure token used for authenticating the lobby with the OpenGB backend.BACKEND_ENDPOINT
The public endpoint URL for the OpenGB backend.Lobby & player management. Create & join lobbies instantly.
The lobbies module is a casual matchmaker optimized to get your player connected to your game server in under a second in the optimal region & lobby.
Supports multiple backends, including:
To integrate your servers to the Lobbies system, you need to call these three scripts in your server code.
set_lobby_ready
: Notifies the lobbies system that the server is ready to accept playersset_player_connected
: Notifies the lobbies system of a player connection while confirming the connection’s legitimacyset_player_disconnected
: Notifies the lobbies system of a player disconnectionAnd don’t worry about notifying the lobbies system if your lobby closes or crashes, that gets taken internally by the Dynamic Server system. Although if you want to manually tell the lobbies system to stop letting in new players, you can call the lobbies.setClosed
endpoint.
Once integrated, you can call the following scripts to find and join available lobbies in your client code.
find
: Finds an available lobby and grants a player token to connectjoin
: Given a lobby’s id, grants a player token to be used for connectionIf you want the client to be able to create a whole new lobby (for things like private games), you can also use the create
script.
Additionally, you can make use of these scripts to get more information about your game’s lobbies.
list_regions
: Returns listing of all regions available in gamelist
: Returns listing of all the lobbies linked to the lobbies systemlobbies.players.getStatistics
: Returns player count statistics by region and game modeThe Lobbies system is tightly integrated with Dynamic Servers to automatically boot lobbies on-demand when players need them. Read more about how Dynamic Servers operates your game servers here.
This document explains the logic going on behind the scenes when a game calls find.
Lobbies will return the lobby in the closest region with the least spots available (i.e. max players - current players
).
If no region is specified in find, OpenGB will use the GeoIP location provided by Cloudflare to find the nearest datacenter.
GeoIP does not always provide the most optimal route to the datacenter, so we recommend providing the user with the ability to select their own region.
Once the region has been determined, Lobbies will filter out full lobbies and then find the fullest lobby (i.e. least available spots).
find allows the developer to provide multiple game modes to join. In this case, Lobbies will select the optimal lobby from all of the provided game modes.
This can be helpful for games with low traffic but still want to provide multiple game modes to their users. In this situation, new players will be connected to any lobby for any game mode with players in it.
When all of the lobbies are full or there are no lobbies running, Lobbies will automatically create a new lobby for the game mode specified and connect the player to that lobby.
If this is not the desired behavior, find can be called with prevent_auto_create_lobby
as true
. This will return a MATCHMAKER_NO_AVAILABLE_LOBBIES error when no lobby can accept players.
Player counts in a given region usually fluxuate by at least 50% ever day during off hours. Games often feel more empty than they actually are as players are leaving the game because there are more lobbies with less players spread evenly across them.
For example:
Even though there are twice as many players online at 10 PM as there were at 9 AM, there are less players in each lobby.
Lobbies is designed to mitigate this issue by prioritizing filling a few lobbies instead of spreading players across all lobbies.
Take our example at 10 PM where there are 5 lobbies with 2 players in each lobby. If 2 new players come online, they will all be put in the same lobby, so one of the lobbies will have 4 players in it while the rest still have 2 players in them..
In our example, we still have 4 lobbies with only 2 players online.
We recommend prompting players to find a new lobby when the lobby is almost empty. By having the players in these empty lobbies call find_or_create
again, the players will be compacted in fewer, fuller lobbies.
The OpenGB uses the client’s IP address to determine the closest region. This allows us to find the optimal lobby for the player and connect them to a lobby in under a second.
If you want to implement your own region selection logic, use list_regions
to list all enabled regions for your game.
We use Cloudflare’s provided geolocation.
There are a series of existing GeoIP databases with varying accuracy that we researched. However, we found that Cloudflare provides the most consistently accurate client location since they have more routing information than just the client’s IP to work with.
The following environment variables are automatically set for each lobby:
LOBBY_ID
A unique identifier for the lobby. This is a UUID string.LOBBY_VERSION
The version of the lobby, as specified in the lobby configuration.LOBBY_TOKEN
A secure token used for authenticating the lobby with the OpenGB backend.BACKEND_ENDPOINT
The public endpoint URL for the OpenGB backend.