Using Rich Presence in Game
This how-to walks you through how to use rich presence in your game.
Prerequisites
Rich Presence
Rich Presence does not require any changes for setup in the SDK.
Sending Status Changes
When sending state changes for a player, you need to provide:
A status name
E.g. "main_menu", "level_1", "settings_menu"
Metadata (Optional)
You can include metadata when sending the state update
E.g. "build_version", "game_fps_count"
Sending a Presence status is as simple as calling a function.
Presence uses a Websocket connection. First initialize a user session with REST for any of the authentication methods. When the user is authorized, open up a websocket connection to ws://domain_key.lootlocker.com/game/presence/v1 with the first message being:
You will get back a response saying if you were authenticated or not:
The web socket will disconnect automatically after 1 minute of no activity. We recommend to send a ping once per minute to cover any network delays or interruptions. If the Websocket is disconnected, you will need to reconnect again.
Response:
To send Rich Presence Statuses, send a message with the following structure:
Out of Focus / Pause behaviour
When Auto Connect and Disconnect On Pause is enabled Presence will reconnect and resend the last status that was sent when Presence reconnects.
Conclusion
In this how-to we have used Rich Presence to send a change of game status. To learn how to interpret this information, continue to the View Presence in Web Console.
Last updated