CloudBuilder  2.8.4
Making social games is easy !
Functions
Transaction (key/value storage, also called "units") related tasks

Functions

void CloudBuilder::CUserManager::Balance (const char *aDomain, CResultHandler *aHandler)
 
DEPRECATED void CloudBuilder::CUserManager::Transaction (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::TxHistory (const char *aDomain, const CotCHelpers::CHJSON *aJSONOptions, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::KeyValueRead (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::KeyValueWrite (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::KeyValueDelete (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::BinaryRead (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::BinaryWrite (const CotCHelpers::CHJSON *aConfiguration, const void *aPointer, size_t aSize, CResultHandler *aHandler)
 
void CloudBuilder::CUserManager::BinaryDelete (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 

Detailed Description

Function Documentation

void CloudBuilder::CUserManager::Balance ( const char *  aDomain,
CResultHandler aHandler 
)

Method to retrieve the user's balance.

Parameters
aDomainthe domains on which action must be taken. NULL is used for "private", which means it can only be accessed from this game.
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain : { "Gold" : 100, "Silver" : 10 }
void CloudBuilder::CUserManager::BinaryDelete ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Method to remove data pointed by a single key.

Parameters
aConfigurationJSON allowing for extensible configuration, that may contain:
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • key: name of the key to delete
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain : { "done" : 1, }
void CloudBuilder::CUserManager::BinaryRead ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Method to read a single key containing binary data stored for this user and this domain.

Parameters
aConfigurationJSON allowing for extensible configuration, that may contain:
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • key: name of the key to retrieve
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain : { "url" : "<signed URL>", } CCloudResult.HasBinary() must be true and you can acces to the data through :
void CloudBuilder::CUserManager::BinaryWrite ( const CotCHelpers::CHJSON aConfiguration,
const void *  aPointer,
size_t  aSize,
CResultHandler aHandler 
)

Method to insert or modify a single key represented by binary data Please note that if you have used KeyValueWrite with a key you reuse in BinaryWrite, you will lose your initial JSON data.

Parameters
aConfigurationJSON allowing for extensible configuration, that may contain:
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • key: name of the key to write to
aPointeris the binary array you want to save.
aSizeis the size of the binary array, in bytes.
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain : { "url" : "<signed URL>", }
void CloudBuilder::CUserManager::KeyValueDelete ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Method to delete a single key of the global JSON object stored for this user and domain.

Parameters
aConfigurationis a JSON configuration, that may contain
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • key: name of the key to delete from the global JSON object. BEWARE: if you omit the key, ALL entries will be deleted!
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr and no binary key was passed in the configuration, the json passed to the handler may contain: { "done": 1 }
void CloudBuilder::CUserManager::KeyValueRead ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Method to read a single key of the global JSON object stored for this user and this domain.

Parameters
aConfigurationis a JSON configuration, that may contain
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • key: name of the key to retrieve from the global JSON object (if not passed, all keys are returned)
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr and no binary key was passed in the configuration, the json passed to the handler may contain: { "<key1>" : "value1", "<key2>" : "value2", ... }
void CloudBuilder::CUserManager::KeyValueWrite ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Method to insert a key or modify the global JSON object stored for this user and this domain. Please note that if you have used BinaryWrite with a key you reuse in KeyValueWrite, you will lose your initial binary data.

Parameters
aConfigurationJSON allowing for extensible configuration, that may contain:
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • key: name of the key to write to (if not passed, the JSON itself is replaced)
  • data: a JSON containing the object to write
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain: { "<key1>" : "value1", "<key2>" : "value2", ... }
DEPRECATED void CloudBuilder::CUserManager::Transaction ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Deprecated: use TransactionV2. Method to send a transaction for this user.

Parameters
aConfigurationJSON allowing for extensible configuration, that may contain:
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • transaction: a json with the transaction as:
    {"Gold": +100} // a credit
    {"Gold": -100} // a debit
    {"Gold": -100, "Arrow": 10} // a swap
    {"Gold": "-auto"} // resets to zero
    If a balance isn't high enough for debiting one of the units, the handler will receive the HTTP error code 449 (enNotEnoughMoney)
  • description: a string describing the transaction
aHandlerresult handler called when the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain something like:
{
"Gold": 100,
"Silver": 10
}
void CloudBuilder::CUserManager::TxHistory ( const char *  aDomain,
const CotCHelpers::CHJSON aJSONOptions,
CResultHandler aHandler 
)

Method to retreive the history of transactions for this user.

Parameters
aDomainthe domains on which action must be taken. NULL is used for "private", which means it can only be accessed from this game.
aJSONOptionsspecify skip and limit and/or the currency for the history, if empty returns all the transactions. i.e. { "unit" : "Gold", "skip": 10, "limit" : 10}
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if noErr, the json passed to the handler may contain:
"servertime": "2014-10-06T13:59:04.308Z", -- server actual time, to synchronize before any new transaction if needed
"history": [{
"domain": "com.clanofthecloud.cloudbuilder.xxxx",
"ts": "2014-10-06T05:05:38.764Z",
"tx": {
"Gold": -100,
"Silver": 1
},
"desc": "Unit Testing transactions, Zeroing Gold"
}, {
"domain": "com.clanofthecloud.cloudbuilder.xxx",
"ts": "2014-10-06T05:05:38.749Z",
"tx": {
"Gold": 100
},
"desc": "Unit Testing transactions"
}] -- ordered by descending time