Session #
The Session service is responsible for managing states attached to a given user session.
Players who leave an in-progress game create a bad experience for other players. In addition to systems deliberately tailored to prevent AFK and other disruptive behaviors, live-service games often want to manage the game flow such that players are not able to leave a match and start another.
Various Multiplayer services coordinate with the Session service to ensure the platform understands where the player is at all times. The Session service tracks players by assigning each player session a set of attribute keys. This enables several features, including:
- Allowing players to reconnect to an in-progress game instance after a client crash or disconnect.
- Requiring that players reconnect to an in-progress game instance rather than starting a new one.
- Preventing abuse cases such as filling up the matchmaking queue with stale records.
- Allowing clients to recover from intermittent network issues while players are going through the game flow.
Attribute keys #
Within the Session service, players are assigned session attribute keys, which can be found within the OnGameSessionChanged
event. These keys indicate which part of a game flow a player is in.
key | status |
---|---|
MATCHMAKING_ID | entered matchmaking |
GAME_INSTANCE_ID | game instance found |
When a party enters matchmaking, all player sessions owned by that party have a MATCHMAKING_ID
added. Once a game instance has been made and sent to the Game Instance service, all of the players within the game instance have their MATCHMAKING_ID
removed and a GAME_INSTANCE_ID
added.
Once a player makes it through this flow and reachesGAME_INSTANCE_ID
status, the game client waits for aOnHostConnectionDetailsReceived
orOnFailedToAllocateGameInstance
event.
This session-based store of matchmaking and game instance IDs is used by various Multiplayer services to prevent players from attempting actions that don’t make sense in the scenario.
For example, if a player disconnects during a game instance and has an assigned GAME_INSTANCE_ID
, then later reconnects while the same game instance is still being played, the Session service informs the Game Instance service that the player has returned. The Game Instance service confirms that the game instance is ongoing, ensures the player’s new session is assigned the GAME_INSTANCE_ID
, and resends connection details to the player so they can rejoin the game. This behavior can be toggled via the configuration option GameInstanceServiceConfig.reconnect
.