Enable Presence in the SDK
This how-to walks you through how to enable presence in your game.
Prerequisites
Enabling Presence
Basic Presence just needs to be enabled in the SDK and the Web Console, after that, playtime data will automatically be sent to LootLocker to be viewed.
Navigate to Player Settings -> LootLocker SDK. Select Enable Presence

Presence Settings
After Presence is enabled, you can toggle settings to change some of the behaviour.
Auto Connect
Should Presence be connected automatically when a LootLocker Session exists?
Can be controlled at runtime with
LootLockerSDKManager.SetPresenceAutoConnectEnabled()Presence can be manually connected by calling
LootLockerSDKManager.ForceStartPresenceConnection(<callback>, <optional player ulid>)
Auto Pause Presence
Disconnect Presence when application loses focus or is paused
Useful for battery saving
Can be controlled at runtime with
LootLockerSDKManager.SetPresenceAutoDiscconnectOnFocusChangeEnabled()Presence can be manually disconnected by calling
LootLockerSDKManager.ForceStopPresenceConnection(<callback>, <optional player ulid>)
Enable Presence in Editor
Uncheck this if you do not want development to affect your Presence data.
Presence uses a Websocket connection. First initialize a user session with REST for any aof 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:
Interact with the Presence system
For more detailed control, or to read data about the current presence connection there are some interfaces in the SDK you can interact with. The two main use cases are:
Manual control of when presence connections are made.
Read information about the presence connection.
Manual Presence Control
Presence Methods
If auto connect is disabled in the SDK, then when you have authenticated a user with LootLocker you can at any time call LootLockerSDKManager.ForceStartPresenceConnection(<callback>, <optional player ulid>).
To disconnect, call LootLockerSDKManager.ForceStopPresenceConnection(<callback>, <optional player ulid>).
To disconnect all active connections call LootLockerSDKManager.ForceStopAllPresenceConnections().
Presence Connection Information
Presence Methods
To check if presence is currently connected for a player, call LootLockerSDKManager.IsPresenceConnected(<optional player ulid>). Or for more granular information, call LootLockerSDKManager.GetPresenceConnectionState(<optional player ulid>).
To see detailed information about the current connection for a player, call LootLockerSDKManager.GetPresenceConnectionStats(<optional player ulid>). This will give you a struct with lots of interesting information, such as the current latency towards LootLocker and how long the connection has been running.
Conclusion
In this how-to we have enabled Basic Presence in the SDK. To learn how to interpret this information, continue to the View Presence in Web Console or continue to read up on Rich Presence and it's use cases.
Last updated