![]() |
CloudBuilder C++ SDK
v3.0.0
Making social games is easy !
|
When working on your new game, one of the first things you will want to do is saving some information about this user. By using Clan of the Cloud APIs for storing information, it will be available from any of the devices this user will use to log in with his Clan of the Cloud profile. You can ensure this way that your players will enjoy the same experience, and this also acts a backup in case a device is lost. Storing some user's information in the cloud is possible with Clan of the Cloud APIs of course, but you have many different ways to achieve this. We will detail below the possibilities that are available to the developer, and will explain when to use them, since some APIs are better suited depending on what you want to save.
The most flexible way to store any kind of information for your users is to use the key/value storing feature provided. Each user has a dedicated set of keys and values, that you are free to manage as you wish. There is no restriction, so you can at any time add, modify or remove any keys. It's entirely up to the developer to manage this storage, and Clan of the Cloud will not interfere with it.
Note that you have two options for using this feature. If you don't pass a domain when accessing your keys, then everything will be local to your game. However, if you pass a domain previously created from your 'CloudBuilder Manager' (https://account.clanofthecloud.com/#/share), then your whole set of keys and values will be accessible from all applications which share this domain.
This means first that you theoretically have an unlimited number of sets of keys and values. Then also, be sure when using domains, to make matching Read and Write calls in the same domain, or otherwise you will not be able to read some previously written data in another domain!
Also, if you ignore the "key" entry in your JSON configuration when writing some information, be aware that you are replacing all the existing keys for this user. This option should be used with great care, and only under precise circumstances, or you may lose all the data for your user! In the same way, but without the dramatic consequences, not passing "key" when reading information, you will be returned the whole set of keys associated to this user.
In the following samples, the information stored for a given key is a simple string. However, it could be a whole JSON if you need so. If this were the case, you'd have to adapt the read operation for such a key in order to handle the result as a JSON object, and not as a string.
There is another way to manage player's informations. For generic purposes and complex data, you should use Key/Value as described above. However, if you want to store very simple information like bool, string and number, you can use the User Properties APIs. Specifically, they are mandatory to use when you want to implement match making into your game. It's here that you will store properties which have to be matched against other players' properties so we can return you some possible opponents. But nothing prevents you from using it also for storing other bits of information, if they are trivial, which might never be used for match making (since in match making, it's up to the developer to build the query that will return possible opponents).
Just like with Key/Value APIs, User Properties belong to a domain. Not filling in the domain entry when working with properties means that you want to access it in the default, private domain of the game. If it is the case, then these properties will not be shared amongst different games.