Multiplayer SDK Reference #

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

Pragma provides the following APIs that developers can use to facilitate multiplayer-related processes:

APIUsed byExample tasks
PartyApiPlayer clientJoin a party, send party invites, entering matchmaking
GameInstanceApiPlayer clientCreate, join, or leave a game instance
MatchApiGame serverConnect players to a game instance, end a game

Party API #

Methods #

methoddescription
Initialize()Initializes the client’s party API and synchronizes party state with the platform. Must be called prior to using other functionality on the API.
ForceSync()Forcibly synchronizes the player client party cache with the party information in the Pragma Engine backend. This includes refreshing received party invite data.
CreateParty()Creates a new party
SendPartyInvite()Sends a party invite to a specific player
CancelPartyInvite()Cancels a sent party invite
AcceptPartyInvite()Accepts another player’s invite to a party
DeclinePartyInvite()Declines another player’s invite to a party
JoinPartyWithInviteCode()Joins a party using an invite code
JoinPartyWithId()Joins a party using a party ID
LeaveParty()Leaves a party voluntarily
AssignPartyLeader()Assigns a party leader
KickPlayerFromParty()Forcibly removes a player from a party
UpdatePartyPlayer()Updates custom party player information when in a party
UpdateParty()Updates custom party information
SetPartyPlayerReady()Sets the player’s Ready value
SetPartyPreferredGameServerZones()Updates the GameServerZones value for the party
SetPartyPlayerGameServerZoneToPing()Updates the GameServerZoneToPing value for the party
EnterMatchmaking()Enters the party into matchmaking once all players are ready. Only a party leader can enter a party into matchmaking.
LeaveMatchmaking()Removes a party from matchmaking
GetMatchmakingInfo()Gets matchmaking queue information
GetPartyCache()Gets the player’s party cache
GetReceivedPartyInvites()Gets a list of received party invites for the player
GetReceivedPartyInviteByInviteId()Gets party invite object by party invite ID
GetReceivedPartyInviteByInviterId()Gets party invite object for invite sent by a specified player to the current player

Events #

EventTriggerData returned
OnJoinedPartyA player joins a partyPragma Party
OnPartyUpdatedParty information changes, including creation and destruction

Note: All other applicable On* events fire in addition to this one, so developers will need to account for handling multiple events at once.
Pragma Party
OnPartyInviteCodeChangedA new invite code is made for the partyinvite code
OnExtBroadcastPartyChangedThe public ext party selections changeExtBroadcastParty
OnPartyPreferredGameServerZonesChangedA party’s preferred game server zones changeArray of preferred game server zones
OnLeftPartyYour player leaves the party voluntarilyN/A
OnRemovedFromPartyYour player leaves a party for reasons outside of your controlRemoval reason (REMOVAL_REASON_UNSPECIFIED, KICKED, LEFT, DISCONNECTED, EXPIRED, or UNRECOGNIZED)
OnPartyPlayersChangedOne or more players join or leave the partyList of Pragma Party Players
OnPlayerJoinedPartyA new player joins the party. All players in the party can handle this eventPragma Party Player for the player that joined the party
OnPlayerLeftPartyA player leaves the partyPragma Party Player for the player that left the party
OnPartyPlayerDataChangedAny player information changesPragma Party Player for the player whose data changed
OnExtPrivatePlayerChangedA player’s private selections changesExtPrivatePlayer
OnReceivedPartyInvitesChangedA received party invite changesList of Pragma Party Invites
OnPartyInviteReceivedA party invite is received from another playerPragma PartyInvites
OnReceivedPartyInvitesCancelledA received party invite is canceled by the inviterPragma Party Invites
OnPartyInviteRevokedA received party invite is removes because a new invite from the same player is receivedinvite ID
OnPartyInviteSentAny player in the party sends an invite. Fires for all players in the party.Pragma Party Invite
OnPartyInviteAcceptedAn invitee joins the party. Fires for all players in the party.Pragma Party Invite
OnPartyInviteDeclinedAn invitee declines the invite. Fires for all players in the party.Pragma Party Invite
OnPartyInviteCancelledAn inviter or party leader cancels a sent party invite. Fires for all players in the party.Pragma Party Invite
OnGameClientVersionUpdateRequiredThe player client needs to update their GameClientVersionN/A
OnPartyClientVersionMismatchCannot find a game server version that is compatible with every player in the partyN/A
OnEnteredMatchmakingParty enters matchmakingN/A
OnLeftMatchmakingParty leaves matchmakingN/A
OnMatchmakingFailedThere is a failure in matchmakingFailure reason (UNSPECIFIED or GAME_SERVER_VERSION_NO_LONGER_COMPATIBLE)

Game Instance API #

Methods #

methoddescription
Initialize()Initializes the client’s game instance SDK and synchronizes its game instance state with the platform’s game instance state. Must be called prior to using other functionality on the API.
ForceSync()Forcibly synchronizes the player client’s game instance data with the game instance information in the Pragma Engine backend
Create()Creates a new game instance
Join()Request to join a specific game instance
Update()Requests updates to data for a specific game instance, identified by GameInstanceId
Leave()Requests that the current player be removed from a game instance, identified by GameInstanceId
GetGameInstanceCache()Gets the player’s game instance cache

Events #

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)

Match API #

Methods #

methoddescription
RequestStartGame()Requests the game start data for a game instance
ConnectPlayers()Connects the initial players to the game server
ConnectMorePlayers()Connects more players to the game server
VerifyPlayer()Uses player connection token to verify that connecting players are not misrepresenting their Pragma identity
UpdateGameInstance()Requests game instance data updates
RemovePlayers()Removes players from a game instance and processes player game results. Does not end the game instance.
EndGame()Request that a game instance end. Does note automatically end the game instance.
EnterMatchmaking()Enters a game instance into matchmaking to accept additional players
LeaveMatchmaking()Removes a game instance from matchmaking
SetRichPresence()Sets a player’s rich presence based on server-side options (such as “in party”)
StartReportCapacityPolling()Used with the Pragma Fleet service. Starts a background task that polls the platform with ReportCapacity RPC calls.
ReportFreedCapacity()Used with the Pragma Fleet service. Releases one unit of game capacity. If the used capacity is currently full, this will result in ReportCapacity RPC calls telling the platform it is available for a new game.
UpdateMaxGameInstanceCount()Used with the Pragma Fleet service. Updates the server’s max game instance count used in ReportCapacity polling.

Events #

EventTriggerData returned
OnGameStartA game instance is started. The game server receives game instance data on this event.Pragma Game Instance Game Start
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
OnPlayersAddedThe platform adds players to a game 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 Pragma Game Instance Game Server Player
OnPlayersRemovedPlayers are removed from the game instance by the backed.game instance ID, list of Pragma Game Instance Game Server Player
OnGameInstanceEnteredMatchmakingThe given active game instance enters matchmakinggame instance ID
OnGameInstanceLeftMatchmakingThe given active game instance leaves matchmakinggame instance ID