The connection flow (or allocation flow) is the process by which the Allocations service reserves slots on a Relay server to group players into a match. The process involves two types of players: joining playersA connecting player (or joining player) is a player that wants to join a host player for a game session on a Relay server. and host playersA host player is a player that initiates a game session on a Relay server and generates a join code to share with other players. There is only one host player per game match.. The following list describes the high-level steps involved in the connection, or allocation, process.
The host player initiates the connection flow by requesting an allocation from the Allocations service. The allocation request includes the maximum number of connectionsAn integer that indicates the maximum number of peer connections a client allows to communicate with them. This parameter must be less than or equal to 100. the allocation should allow. It can also include a specific region. If the request doesn’t include a region, the Allocations service uses QoS to select the best region for the request.
The host uses the connection data from the Allocations service's response to bind the Allocation service selected for the allocation to the Relay. The Relay server selection depends on the maximum connections allowed and the region.
When the Allocations service finds a Relay server, it makes a call to allocate or reserve a space on the Relay server for the game session. At this point, the Relay server also generates a unique secret key. The Relay server returns the secret key to the Allocations service, in addition to the Relay server IP, the Relay server ports, and the connection data.
The Allocations service sends the Relay server connection data to the host player's game client.
The host uses the connection data from the response from the Allocations service to send bind to the Relay the Allocation service selected for the allocation. The
BIND message contains the connection data, the accept modeThe accept mode defines how a Relay server should handle requests from clients trying to connect. The accept mode is always AUTO., nonce, and HMAC. If the host doesn’t send the bind to the Relay server within 10 seconds after making the allocation, the allocation times out from inactivity.
If the information in the request is accurate, the Relay server sends an acknowledges that the player is bound.
Once bound to the Relay server, the host player can request a join code from the Allocations service.
The Allocations service generates and returns a join code to the host player. The join code the Allocations service returns uniquely represents the host player’s allocation to the Relay server, and allows joining players to connect to the host player and bind to the same Relay server.
The host player shares the unique join code with other players through any method, including verbally, through a text message, or through a Lobby. The join codes are short and easy to remember to facilitate sharing.
The players that use the join code with a join request to the Allocations service become the joining players.
The joining players use the join code from the host player to send a join request to the Allocations service.
The Allocations service uses the join code to look up the host player’s allocation and the associated connection data, then sends the connection data to the joining players.
The response from the Allocations service contains the Relay server IP address, the Relay server port, the secret key, the encrypted joining player’s connection data, the joining player’s allocation ID, and the encrypted host connection data. The joining player can then use the secret key to decrypt and use the host connection data to connect to the host.
The joining player uses the connection data from the Allocations service to bind to the Relay server.
Once bound to the same Relay server as the host player, the joining player can send a connection request to the host player. If the connection request is successful, the joining player and the host players can send data to each other through the Relay server.