Game Instance Reference #

Game Instance service SDK #

The Pragma SDK provides methods that developers can use to facilitate game instance processes, such as connecting more players or ending the game. The SDK includes methods for Game Instance service implementation through the GameLoopApi and MatchApi classes, depending on whether the call comes from the game client or game server, respectively. The tables below contains a list of all the GameLoopApi and MatchApi methods relevant to the Game Instance service.

GameLoopApi (player client) SDK methods #

Calldescription
DeclineReconnectSignals that the player is declining to reconnect to the game instance after disconnecting.
GetHostConnectionDetailsProvides player with connection information for the game instance. This is useful for a player if they disconnect and later decide to reconnect.

MatchApi (game server) SDK methods #

Calldescription
ConnectMorePlayersConfirms the connection details and game instance ext data for the found players.
ConnectPlayersSignals a game instance is ready to start.
EndGameSignals a game instance has completed.
RemovePlayersProcesses player game results for a subset of players within a game instance. Does not end the game instance.
EnterMatchmakingAllows an active game instance to enter matchmaking to accept additional parties.
LeaveMatchmakingRemoves an active game instance from matchmaking.
VerifyPlayerUses player connection token to verify that connecting players are not misrepresenting their Pragma identity.
KeepAliveTaskEnsures a game instance does not get ended by the Game Instance service.
UpdateGameInstanceTriggers an update of the custom data held within the platform for a game instance.
RequestStartGameIf not using the Fleet service, use to request game start data for a known game instance.

The SDK calls invoke various Game Instance Plugin methods through Game Instance service RPCs. For a list of Game Instance service RPCs, see the GameInstance reference page.

Game Instance service plugins #

The GameInstancePlugin, GameInstanceHostPlugin, and GameInstanceMatchmakingPlugin allow developers to implement custom game instance functionality. In the Game Instance Tasks topic we’ll see how these methods can be used, along with the SDKs that invoke them. You can view all the Game Instance Plugin methods and their properties on the Game Instance Plugin reference page, Game Instance Host Plugin reference page, and the Game Instance Matchmaking Plugin reference page.

Data classes #

For information on the NewGameInstance and GameInstanceUpdate class, see Matchmaking Reference.

Game instances #

GameInstance represents a running game instance, and includes details about the parties, players, and a custom-defined payload of extra game information that will be used to create the game instance.

property/methoddescription
idUnique GameInstanceId of the game instance
playersList of players in the game instance
partiesList of parties in the game instance
gameServerZoneThe game server zone the game instance is using
inMatchmakingBoolean value indicating whether the GameInstance is currently enrolled within matchmaking to find more players
removedPlayersList of players previously removed from the game instance
extThe ExtGameInstance created during matchmaking in the NewGameInstance

Game parties #

GameParty represents a party within a game instance.

propertydescription
idUnique party ID
playersList of players in the game instance
extThe ExtGameParty set by the NewGameInstance and GameInstanceUpdate. Used to store unique data for a party in a game instance.

Game players #

GamePlayer represents a player within a game instance.

propertydescription
playerIdUnique player ID
socialIdUnique social ID
displayNamePlayer’s public display name
partyIdParty ID for the party the player belongs to
teamNumberPlayer’s assigned team number
extThe ExtGamePlayer created during matchmaking in the NewGameInstance or GameInstanceUpdate. Used to store unique data for a player in a game instance.

Game start #

GameStart represents data sent to the game server when a game server is allocated for a game instance.

propertydescription
gameInstanceIdUnique game instance ID
playersAndExtsList of GamePlayer and ExtGameServerPlayer
extThe ExtGameStart used to store custom data to send to the game server

PartnerClientTokens #

The PartnerClientTokens class contains data for partner client tokens that the game server should use when authenticating to Pragma.

propertydescription
gameTokenPartner client token to use when authenticating to Pragma game backend
socialTokenPartner client token to use when authenticating to Pragma social backend

Configuration #

The GameInstanceServiceConfig configuration block provides a place to define default values for the Party service. The following configuration values are available:

configdescription
gameReadyTimeoutMillisTime, in milliseconds, to wait for a game server to send a connect players request before releasing the players attached to the game instance
enableAbsoluteTimeoutEnables the absolute timeout that will release a game from the service after a specific amount of time has elapsed
absoluteTimeoutMillisTime, in milliseconds, to wait before releasing a game instance. A 0 or negative values means games will never timeout. This value will be ignored if enableAbsoluteTimeout is false.
enableKeepAliveEnables the keep alive interval, which specifies the interval within which a game server needs to send a keep alive request. If the game server does not send a request within this interval, the the game instance will be released from the service.
keepAliveIntervalMillisInterval, in milliseconds, to wait between keep alive requests. This value will be ignored if enableKeepAlive is false.
keepAliveMissesLimitNumber of keep alive request the game server can miss before releasing the game instance from the service. This value will be ignored if enableKeepAlive is false.
reconnectDetermines the player client behavior when recovering from an unexpected disconnect during a game.
useFleetServiceEnables the usage of server pools.

Extension data #

You can use Extension Data (exts) to pass custom information between different Pragma components for the duration of the game instance. Fields in the various exts can be stored on the engine, or forwarded to plugins, game servers, and player clients through other exts. Using exts to define when and how certain data travels between two components allows you to control each component’s access to certain data. See Game Instance Tasks for sample implementation.

The following table lists the ext payloads relevant to game instance information.

extdescriptionExample data
ExtRemovePlayersRequestGame instance data sent from the game server to the Game Instance Plugin’s onRemovePlayers method when a group of players are removed from a game instance.game time elapsed at removal time
ExtRemovePlayerPlayer data passed from the game server to the Game Instance Plugin’s onRemovePlayers method via the playerToRemove list when a player is removed from a game instance.player’s progress on current mission
ExtRemovedFromGamePlayer data populated by the Game Instance Plugin’s onRemovePlayers method and sent to the removed player client in the OnRemovedFromGame notification when the player is removed from a game instance.rewards delta
ExtEndGameRequestGame instance data sent from the game server to the Game Instance Plugin’s onEndGame method when a game instance ends.game metrics
ExtPlayerGameResultPlayer data passed from the game server to the Game Instance Plugin’s onEndGame method via the PlayerGameResult list when a game instance ends.completed missions, points gained
ExtGameEndedPlayer data populated by the Game Instance Plugin’s onEndGame method and sent to the player in the OnGameEnded notification when a game instance ends. Players previously removed from the game instance can still receive this information.rewards delta
ExtAddedToGameGame instance data populated by the Game Instance Plugin’s buildExtAddedToGame method and sent to the player client in the OnAddedToGame notification when the player is added to a game.team color, current game score
ExtGameInstanceGame instance data populated by the Matchmaking Plugin’s matchParties method and sent to the Game Instance Service when a new game instance is created. This data will be used when creating the new game instance and persists on the engine for the duration of the game instance.max game instance duration, game mode, map
ExtGamePartyParty data populated and passed to the Game Instance service when the Matchmaking service creates a NewGameInstance or GameInstanceUpdate. The data persists on the engine for the duration of the party’s time in the game instance and can be updated during subsequent plugin calls.custom party data
ExtGamePlayerPlayer data populated and passed to the Game Instance service when the Matchmaking service creates a NewGameInstance or GameInstanceUpdate. The data persists on the engine for the duration of the player’s time in the game instance and can be updated during subsequent plugin calls.Steam ID
ExtGameStartGame instance data provided to the game server starting the game. When the game server is allocated for a game instance, it calls getGameStartDataV1, which invokes the Game Instance Plugin’s buildExtGameStart method. This ext could include data sent to the Game Instance service in the ExtGameParty payload.game instance duration
ExtGameServerPlayerPlayer data provided to the game server by the Game Instance service. When the game server is allocated for a game instance, it calls getGameStartDataV1, which invokes the Game Instance Plugin’s buildExtGameServerPlayer method for each player in the game instance. This ext could include data sent to the Game Instance service in the ExtGamePlayer payload.Steam ID
ExtPlayerConnectionDetailsConnection details populated by the game server and used when a game instance is ready for players to join. Players receive the connect details in the OnHostConnectionDetailsReceived notification.game server zone/region
ExtUpdateGameInstanceRequestPayload sent via the game server’s UpdateGameInstance SDK method defining what updates to make to a game instance.advance the current game phase
ExtHostRequestData to assist in game server allocation. Populated by GameInstanceHostPlugin.findHostForGameInstance and used in the fleet service to determine which server pool to assign for the game instance.

Events #

There are several game instance-related events that player clients and game servers can listen to. The following tables contain bindable events relevant to the Game Instance service, along with associated descriptions of when the event is triggered.

Player client events #

The following events are handled by the player client.

EventTriggerData returned
OnAddedToGameThe player has been added to a game. Will be followed with OnHostConnectionDetailsReceived when the game server is ready.Pragma ID, ExtAddedToGame
OnHostConnectionDetailsReceivedThe game server starts a game instance and is available for parties to connecthost name, port, game instance ID, ExtPlayerConnectionDetails, unique connection token
OnFailedToAllocateGameInstanceGame instance allocation fails due to game server issues after matchmaking succeedsN/A
OnGameInstanceTerminatedA game instance is forcibly terminated because it’s no longer communicating with the enginegame instance ID, termination reason (UNSPECIFIED, KEEP_ALIVE_FAILED, or ABSOLUTE_TIMEOUT_ELAPSED)
OnGameInstanceReconnectConnection to the platform is established after disconnecting during an active game instancehost name, port, game instance ID, ExtPlayerConnectionDetails, unique connection token
OnRemovedFromGameThe game server has removed the player from the gamegame instance ID, ExtRemovedFromGame
OnGameEndedThe game has endedGame instance ID, ExtGameEnded
OnGameInstanceIdChangedThe GAME_INSTANCE_ID for the game instance changes in the Partynew game instance ID

Game server events #

The following events are handled by the game server.

EventTriggerData returned
OnGameStartGame instance data is retrieved using the provided game instance IDGameStart
OnGameStartFailedAn error occurs when attempting to retrieve game instance data with the provided game instance IDPragma error
OnKeepAliveFailedThe platform fails to process a keep alive requestgame instance ID, Pragma error
OnGameInstanceTerminatedThe platform decides to terminate an in progress game instance. An example of this firing is when a game instance has failed to heartbeat due to connection issues to the platform. Calling EndGame will not cause this event to fire.game instance ID, termination reason
OnAddPlayersThe platform sends new players to the game server to add to the game instance. Upon receiving, the game server should invoke ConnectMorePlayers with prepared details for the provided new players for the provided game instance id.game instance ID, list of Game players
OnGameInstanceEnteredMatchmakingThe given active game instance enters matchmakinggame instance ID
OnGameInstanceLeftMatchmakingThe given active game instance leaves matchmakinggame instance ID
OnPlayerDeclinedReconnectA player declines to reconnect to the game they were in. Includes the game instance ID and player ID respectively.game instance ID, player ID

Errors #

  • GameInstanceService_CapacityRequestFailed
  • GameInstanceService_UnknownGameInstanceId
  • GameInstanceService_PlayerNotInGameInstance
  • GameInstanceService_GameInstanceAlreadyInMatchmaking
  • GameInstanceService_MissingPlayerConnectionDetails
  • GameInstanceService_CannotDeclineReconnect
  • GameInstanceService_FailedToUpdateMatchmakingGameInstancePlayers
  • GameInstanceService_FailedToLeaveMatchmaking
  • GameInstanceService_GameInstanceNotInMatchmaking
  • GameInstanceService_FailedToUpdateMatchmakingGameInstance