Documentation

Multiplayer Services SDK

All Services

Multiplayer Services SDK

Relay integration

Integrate Unity Relay with Lobby to enable synchronized disconnects and secure peer-to-peer communication between players.
Read time 1 minuteLast updated a day ago

Note
Interoperability between relay and lobby is handled for users when using Multiplayer sessions. However you can use additional settings for more fine grained control over your relay and lobby multiplayer set up.
Using the Relay service isn't a requirement for using the Lobby service, but if you're using Relay, you can set Relay-related properties on a lobby 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 server they're connected to, the Relay service sends a notification to the Lobby service so that the disconnected player is removed from that lobby. Refer to the Relay documentation for more information about Relay and the Lobby config options for more details about configuring player disconnects. To enable Relay integration with the Lobby service, set the AllocationID for each player whenever a player is in a lobby and is using a Relay server. The AllocationID for the player who sets up the allocation (most likely the lobby host) should be the allocation ID returned by the CreateAllocationAsync API call. All other players in the lobby who join that allocation should instead use the allocation ID returned by their respective JoinAllocationAsync API calls.
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.