ChilliConnect's Cloud Data feature provides you with the ability to save persistent data from your game in the cloud, in the form of Player Data.
Player Data is primarily suited for data that is tied to a specific player and does not need to be searched for or updated by other players. Use cases for player data include:
- Save game state
- Player preferences
Player Data is allows you to save bespoke data against a ChilliConnect player. You can save any kind of data you want - for example, game progression and player preferences are good examples of the type of data that can be saved in Cloud Data. Saved data is persisted on the ChilliConnect servers and can be retrieved on any device, allowing your game to easily support cross platform play.
All data saved in Player Data is attached to a specific Key that describes the Data. For example,
Level are examples of good Player Data names. Data is saved using the SetPlayerData method.
Up to 10 Keys can be stored against a single player. Keys can be up to 50 characters in length, with values up to 7kb, and an Attachment which is a string up to 2mb in size. If you attempt to save a new Key when the player already has 10 Keys stored, an error will be returned. Existing Keys can also be removed with the DeletePlayerData method.
Data stored against the currently logged in player is retrieved through the GetPlayerData method. You can provide a list of Keys to return specific data, or omit the Keys to retrieve all stored Keys for the player.
Player Data also allows you to retrieve a specific Key for the currently logged in player's facebook friends via the GetPlayerDataForFacebookFriends method. This makes it easy to share read only information such as game progression or last level played for example between Facebook friends.
Similarly, GetPlayerDataForChilliConnectIds can be used to retrieve a specific Key for a list of ChilliConnectIDs. This can be used in combination with the ChilliConnectIds returned from a GetScores request, for example, to retrieve additional read only information on other ChilliConnect players when displaying Leaderboard scores in your game.
In order to better support offline play on multiple devices, Player Data also provides the ability to detect potential conflicts when attempting to save new data. When data for a particular Key or set of Keys is retrieved, ChilliConnect will return a
WriteLock value for that Key. The
WriteLock represents an identifier to the current version of the data that has been read. In order to implement conflict checking, simply supply the
WriteLock when next attempting to save data to that particular key.
If the currently stored
WriteLock differs from the
WriteLock supplied (meaning that the device attempting to update the Key does not have the latest version), then an error will be returned. The
data property of the error will include the currently stored data as well as date and time the data was last modified so that you can either resolve the conflict programmatically, or present the data to the player and allow them to select the correct version.
See the full documentation for the SetPlayerData method for more details on how to use the
WriteLock for conflict checking.
Additionally each Player Data Key can store an Attachment. An Attachment is a string up to 2mb in length - serialise binary, zip or other structured data to a string format such as base64 encoding. Attachments are used for larger pieces of data such as saved game state. For performance Attachment data is not sent with the GetPlayerData response, but accessed individually from either the GetPlayerDataAttachment or GetPlayerDataAttachmentForChilliConnectID methods.
Viewing Player Keys
Keys saved against against a particular player are also viewable through the ChilliConnect Dashboard. From the player screen, simply select the "Player Data" tab: