Presence Reference #
Presence SDK #
The table below contains a list of the SDK methods relevant to the presence feature. These methods are available via the PresenceApi
.
Call | description |
---|---|
Initialize | Initialize the Presence API. Required to use the Presence SDK functions. |
SetAsOnline | Appear as “online” to friends in the game instance |
SetAsAway | Appear as “away” to friends in the game instance |
SetRichPresence | Set rich presence |
SetPresence | Set basic presence and rich presence at the same time |
GetPresence | Retrieve presence status for current player |
ForceSync | Forcibly synchronize the player client PresenceApi with the presence information in the Pragma Engine backend |
The Presence Plugin #
The Presence Plugin provides a location for developers to implement custom presence functionality, such as handling the rich presence ext
. The Presence Tasks topic shows example usage of the Presence Plugin methods, along with the SDKs that invoke them.
Presence class #
property | description |
---|---|
socialId | Unique social identifier for the player (game agnostic) |
playerId | Unique player ID |
gameShardId | Unique identifier of the game shard associated with this presence object |
gameTitleId | Title of the game associated with the gameShardId. See Game Title Management in the Portal documentation for more information of game shard/game title mapping. |
basicPresence | BasicPresence object representing whether the user appears “online” or “away”. See following table. |
ext | Custom ExtRichPresence payload containing custom data to display to friends |
Basic presence enum #
property | description |
---|---|
online | User’s presence status is “online” |
away | User’s presence status is “away” |
Extension data #
You can use Extension Data (exts
) to define custom data about player presence statuses. See Presence Tasks for sample implementation.
The following table lists the ext
payloads relevant to presence information.
ext | description | example data |
---|---|---|
ExtRichPresencePlayerRequest | Custom presence values set/updated by the player client | custom away message |
ExtRichPresenceBackendRequest | Custom presence values set/updated by the game server | current score |
Configuration #
The FriendsServiceConfig
configuration block provides a place to define default values for the Friend and Presence services.
The following configuration values are related to Presence features:
config | description |
---|---|
enablePresenceUpdates | Enable or disable ability to update presence statuses. If false , a player’s basic and rich presences cannot be updated. The Presence API’s GetPresence method is still available and will return presence values (if any) at the time enablePresenceUpdates was set to false .Default: true |
See Friend Reference for information on other configuration values.
Events #
The following events are related to the Presence feature.
To optimize server-load management, Pragma engine only sends Presence-related events to friends who are online.
Event | Trigger | Data returned |
---|---|---|
OnPresenceChanged | Your presence status changes | the new Presence |
OnFriendUpdated | A friend’s presence status changes | Friend |
OnFriendListChanged | A friend is added or removed from your list, or a friend’s presence status changes | Friend |
If Pragma Engine detects anOnFriendUpdated
event was missed due to network issues, the entire friend list is fetched again. OlderOnFriendUpdated
notifications are ignored.
Errors #
- Presence_GameIdentityNotFound
- Presence_PresenceNotFound