Relay integration

Using the Relay service isn’t a requirement for using the Lobby service, but if you are using Relay, you can set relay-related properties on a lobby if you want to enable synchronized disconnects between relay and lobby. If you register a player's relay information with the lobby, and that player disconnects or is disconnected from the relay they are connected to, the Relay service sends a notification to the Lobby service so that the disconnected player is removed from that lobby. See the Relay documentation for more information.

To enable relay integration with the Lobby service, you must set the AllocationID for each player whenever a player is in a lobby and is using a relay. The AllocationID should be the relay allocation ID returned by the CreateAllocationAsync API call.

There is also an optional per-player ConnectionInfo field, which you can set for any player (usually the relay host) as a way to provide information on how to connect to a relay hosted by that player.

You can use the Game Lobby Sample which demonstrates how to use the Lobby and Relay packages to create a typical game lobby experience.

Note: When you are using relay integration and the relay host disconnects from the relay, the host is removed from the lobby. Other players are also disconnected from the relay at this time (because the host is gone), but they are not disconnected from the lobby. For more information, see Host migration.

Check out the Lobby and Relay demo overview to learn about how you can use Lobby and Relay together to create a game that facilitates multiplayer game sessions without dedicated game servers.