Game Instance SDK Reference #

This section provides references for Game Instance methods, classes, and events in the Pragma SDK for Unreal and Unity. For information on Pragma Engine backend classes and plugins, see Game Instance Backend Reference.

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

Game Instance API (player client) SDK methods #

Calldescription
InitializeInitializes the client’s party API state and synchronizes its party state with the platform’s party state. Must be called prior to using other functionality on the API.
ForceSyncForcibly synchronizes the player client’s game instance data with the game instance information in the Pragma Engine backend
UpdateRequests game instance data updates
DeclineReconnectSignals that the player is declining to reconnect to the game instance after disconnecting
GetGameInstanceCacheGets the player’s game instance cache

Match API (game server) SDK methods #

Calldescription
RequestStartGameRequests the game start data for a game instance
ConnectPlayersConnects the initial players to the game server
ConnectMorePlayersConnects more players to the game server
VerifyPlayerUses player connection token to verify that connecting players are not misrepresenting their Pragma identity
UpdateGameInstanceRequests game instance data updates
RemovePlayersRemoves players from a game instance and processes player game results. Does not end the game instance.
EndGameRequest that a game instance end. Does note automatically end the game instance.
EnterMatchmakingEnters a game instance into matchmaking to accept additional players
LeaveMatchmakingRemoves a game instance from matchmaking
SetRichPresenceSets a player’s rich presence based on server-side options (such as “in party”)

The SDK calls invoke various Game Instance Plugin methods through Game Instance service RPCs.

Unreal classes #

The SDK for Unreal makes use of Pragma-defined Unreal classes. The following sections list methods available on each class:

FPragmaGameInstance #

methodreturns
GetId()game instance ID
GetDataStore()map of data store key and FPragma_GameInstance_ExtData
GetHostConnectionDetails()FPragmaHostConnectionDetail
GetPlayers()List of FPragmaGamePlayers
GetPlayer(const FString& PlayerId)FPragmaGamePlayer
GetVersion()game instance version

FPragmaGameInstanceCache #

methodreturns
IsInGame()true/false
GetGameInstanceFPragmaGameInstance

FPragmaGamePlayer #

methodreturns
GetPlayerId()player ID
GetDataStore()map of data store key and FPragma_GameInstance_ExtData

FPragmaHostConnectionDetails #

methodreturns
GetHostName()hostname
GetPort()port number
GetConnectionToken()connection token (string)
GetExt()FPragma_GameInstance_ExtPlayerConnectionDetails

FPragma_GameInstance_GameStart #

propertydefinition
GameInstanceIdgame instance ID
PlayersList of FPragma_GameInstance_GameServerPlayer
ExtFPragma_GameInstance_ExtGameStart

FPragma_GameInstance_GameServerPlayer #

propertydefinition
PlayerIdplayer’s ID
SocialIdplayer’s social ID
DisplayNameplayer’s display name
PartyIdparty ID
TeamNumberplayer’s team number
ClientVersionclient version
ExtFPragma_GameInstance_ExtGameServerPlayer

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
OnAddedToGameInstanceThe player has been added to a game instance. Will be followed with OnHostConnectionDetailsReceived when the game server is ready.GameInstance
OnGameInstanceUpdatedA game instance is updated due to player client requestGameInstance
OnFailedToAllocateGameInstanceGame instance allocation fails due to game server issues after matchmaking succeedsN/A
OnHostConnectionDetailsReceivedThe game server starts a game instance and is available for parties to connectGameInstance
OnRemovedFromGameInstanceThe game server has removed the player from the gamegame instance ID, ExtRemovedFromGame
OnGameInstanceEndedThe game has endedGame instance ID, ExtGameEnded
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)

Game server events #

The following events are handled by the game server.

EventTriggerData returned
OnGameStartA game instance is started. The game server receives game instance data on this event.FPragma_GameInstance_GameStart
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
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 FPragma_GameInstance_GameServerPlayer
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 instance they were in. Includes the game instance ID and player ID respectively.game instance ID, player ID