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:
API | Used by | Example tasks |
---|---|---|
PartyApi | Player client | Join a party, send party invites, entering matchmaking |
GameInstanceApi | Player client | Create, join, or leave a game instance |
MatchApi | Game server | Connect players to a game instance, end a game |
Party API #
Methods #
method | description |
---|---|
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 #
Event | Trigger | Data returned |
---|---|---|
OnJoinedParty | A player joins a party | Pragma Party |
OnPartyUpdated | Party 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 |
OnPartyInviteCodeChanged | A new invite code is made for the party | invite code |
OnExtBroadcastPartyChanged | The public ext party selections change | ExtBroadcastParty |
OnPartyPreferredGameServerZonesChanged | A party’s preferred game server zones change | Array of preferred game server zones |
OnLeftParty | Your player leaves the party voluntarily | N/A |
OnRemovedFromParty | Your player leaves a party for reasons outside of your control | Removal reason (REMOVAL_REASON_UNSPECIFIED , KICKED , LEFT , DISCONNECTED , EXPIRED , or UNRECOGNIZED ) |
OnPartyPlayersChanged | One or more players join or leave the party | List of Pragma Party Players |
OnPlayerJoinedParty | A new player joins the party. All players in the party can handle this event | Pragma Party Player for the player that joined the party |
OnPlayerLeftParty | A player leaves the party | Pragma Party Player for the player that left the party |
OnPartyPlayerDataChanged | Any player information changes | Pragma Party Player for the player whose data changed |
OnExtPrivatePlayerChanged | A player’s private selections changes | ExtPrivatePlayer |
OnReceivedPartyInvitesChanged | A received party invite changes | List of Pragma Party Invites |
OnPartyInviteReceived | A party invite is received from another player | Pragma PartyInvites |
OnReceivedPartyInvitesCancelled | A received party invite is canceled by the inviter | Pragma Party Invites |
OnPartyInviteRevoked | A received party invite is removes because a new invite from the same player is received | invite ID |
OnPartyInviteSent | Any player in the party sends an invite. Fires for all players in the party. | Pragma Party Invite |
OnPartyInviteAccepted | An invitee joins the party. Fires for all players in the party. | Pragma Party Invite |
OnPartyInviteDeclined | An invitee declines the invite. Fires for all players in the party. | Pragma Party Invite |
OnPartyInviteCancelled | An inviter or party leader cancels a sent party invite. Fires for all players in the party. | Pragma Party Invite |
OnGameClientVersionUpdateRequired | The player client needs to update their GameClientVersion | N/A |
OnPartyClientVersionMismatch | Cannot find a game server version that is compatible with every player in the party | N/A |
OnEnteredMatchmaking | Party enters matchmaking | N/A |
OnLeftMatchmaking | Party leaves matchmaking | N/A |
OnMatchmakingFailed | There is a failure in matchmaking | Failure reason (UNSPECIFIED or GAME_SERVER_VERSION_NO_LONGER_COMPATIBLE ) |
Game Instance API #
Methods #
method | description | |
---|---|---|
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 #
Event | Trigger | Data returned |
---|---|---|
OnAddedToGameInstance | The player has been added to a game instance. Will be followed with OnHostConnectionDetailsReceived when the game server is ready. | GameInstance |
OnGameInstanceUpdated | A game instance is updated due to player client request | GameInstance |
OnFailedToAllocateGameInstance | Game instance allocation fails due to game server issues after matchmaking succeeds | N/A |
OnHostConnectionDetailsReceived | The game server starts a game instance and is available for parties to connect | GameInstance |
OnRemovedFromGameInstance | The game server has removed the player from the game | game instance ID, ExtRemovedFromGame |
OnGameInstanceEnded | The game has ended | Game instance ID, ExtGameEnded |
OnGameInstanceTerminated | A game instance is forcibly terminated because it’s no longer communicating with the engine | game instance ID, termination reason (UNSPECIFIED , KEEP_ALIVE_FAILED , or ABSOLUTE_TIMEOUT_ELAPSED ) |
Match API #
Methods #
method | description | |
---|---|---|
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 #
Event | Trigger | Data returned |
---|---|---|
OnGameStart | A game instance is started. The game server receives game instance data on this event. | Pragma Game Instance Game Start |
OnGameStartFailed | An error occurs when attempting to retrieve game instance data with the provided game instance ID | Pragma error |
OnKeepAliveFailed | The platform fails to process a keep alive request | game instance ID, Pragma error |
OnPlayersAdded | The 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 |
OnPlayersRemoved | Players are removed from the game instance by the backed. | game instance ID, list of Pragma Game Instance Game Server Player |
OnGameInstanceEnteredMatchmaking | The given active game instance enters matchmaking | game instance ID |
OnGameInstanceLeftMatchmaking | The given active game instance leaves matchmaking | game instance ID |