CloudBuilder  2.8.4
Making social games is easy !
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
CloudBuilder::CUserManager Class Reference

#include <CUserManager.h>

Public Member Functions

void LoginAnonymous (CResultHandler *aHandler)
 
void LoginNetwork (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void ResumeSession (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void Logout (CResultHandler *aHandler)
 
void Link (const char *aNetwork, CResultHandler *aHandler)
 
void Unlink (const char *aNetwork, CResultHandler *aHandler)
 
void Convert (const char *aNetwork, CResultHandler *aHandler)
 
void UserExist (const char *aIdent, const char *aNetwork, CResultHandler *aHandler)
 
void MailPassword (const CotCHelpers::CHJSON *aJSON, CResultHandler *aHandler)
 
void ChangePassword (const char *aNewPassword, CResultHandler *aHandler)
 
void ChangeEmail (const char *aNewEmail, CResultHandler *aHandler)
 
void SetProfile (const CotCHelpers::CHJSON *aJson, CResultHandler *aHandler)
 
void GetProfile (CResultHandler *aHandler)
 
void SetProperties (CResultHandler *aHandler, const CotCHelpers::CHJSON *aPropertiesList, const char *aDomain="private")
 
DEPRECATED void SetProperties (const CotCHelpers::CHJSON *aPropertiesList, CResultHandler *aHandler)
 
void GetProperties (CResultHandler *aHandler, const char *aDomain="private")
 
void SetProperty (CResultHandler *aHandler, const CotCHelpers::CHJSON *aProperty, const char *aDomain="private")
 
void GetProperty (CResultHandler *aHandler, const char *aField, const char *aDomain="private")
 
void DeleteProperty (CResultHandler *aHandler, const char *aField, const char *aDomain="private")
 
void Balance (const char *aDomain, CResultHandler *aHandler)
 
DEPRECATED void Transaction (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void TxHistory (const char *aDomain, const CotCHelpers::CHJSON *aJSONOptions, CResultHandler *aHandler)
 
void KeyValueRead (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void KeyValueWrite (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void KeyValueDelete (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void BinaryRead (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void BinaryWrite (const CotCHelpers::CHJSON *aConfiguration, const void *aPointer, size_t aSize, CResultHandler *aHandler)
 
void BinaryDelete (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void RegisterEventListener (const char *aDomain, CEventListener *aListener)
 
void UnregisterEventListener (const char *aDomain, CEventListener *aListener)
 
void PushEvent (const char *aDomain, const char *aGamerID, const CotCHelpers::CHJSON *aEvent, const CotCHelpers::CHJSON *aNotification, CResultHandler *aHandler)
 
const char * GetDisplayName ()
 
const char * GetGamerID ()
 
const char * GetMail ()
 
void Publish (const char *aNetwork, const CotCHelpers::CHJSON *aMessage, CResultHandler *aHandler)
 
void GetGodfatherCode (CResultHandler *aHandler, const char *aDomain="private")
 
void GetGodfather (CResultHandler *aHandler, const char *aDomain="private")
 
void SetGodfather (const char *aCode, const CotCHelpers::CHJSON *aOptions, CResultHandler *aHandler)
 
void GetGodchildren (CResultHandler *aHandler, const char *aDomain="private")
 
void Outline (CResultHandler *aHandler)
 
void RegisterForNotification ()
 
void ListAchievements (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void EarnAchievement (const char *aUnit, int aIncrement=1, const CotCHelpers::CHJSON *aGamerData=NULL, CResultHandler *aHandler=NULL)
 
void TransactionExtended (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void SetAchievementData (const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler)
 
void Batch (CResultHandler *aHandler, const CotCHelpers::CHJSON *aConfiguration, const CotCHelpers::CHJSON *aParameters)
 

Static Public Member Functions

static CUserManagerInstance ()
 

Friends

class CClan
 
struct CFacebookGlue
 
class CGooglePlusGlue
 
struct singleton_holder< CUserManager >
 
void publishUserAfterPermission (int err, void *params)
 
void AchieveRegisterDevice (unsigned long len, const void *bytes)
 
FACTORY_FCT void CUserManager_ResetAchievements (const char *domain, CResultHandler *handler)
 

Detailed Description

The CloudBuilder::CUserManager is the second class you will use once you are connected with CloudBuilder::CClan::Setup method. This class manages a user profile. The class is a singleton and is not designed to be overridden. In version 2, we use the concept of delegates to get the results, in the same way it was designed in the C# wrapper.

Member Function Documentation

void CloudBuilder::CUserManager::Batch ( CResultHandler aHandler,
const CotCHelpers::CHJSON aConfiguration,
const CotCHelpers::CHJSON aParameters 
)

Run a user authenticated batch on the server side. Batch is edited on BackOffice server.

Parameters
aConfigurationJSON data describing the dat to pass to the batch
  • domain: the domain on which the action is to be taken (if not passed, the private domain is used)
  • name: the name identifying the batch
aParametersJSON data describing the data to pass to the batch
  • input: user defined data
aHandlerthe handler called with the result when the call completes
Returns
if noErr, the json passed to the handler will contain the result of the executed batch
void CloudBuilder::CUserManager::EarnAchievement ( const char *  aUnit,
int  aIncrement = 1,
const CotCHelpers::CHJSON aGamerData = NULL,
CResultHandler aHandler = NULL 
)

Helper method that allows easily to post a success. For this to work, you need to have an achievement that uses the same unit as the name of the achievement.

Parameters
aUnitthe name of the achievement, and unit to increment
aIncrementby how much to increment the unit; you may as well decrement it by passing a negative value
aGamerDatagamer data to store for the gamer/achievement, merged with the current data (that is, existing keys are not affected)
aHandlerhandler called with the result of a call to CUserManager::Transaction
const char* CloudBuilder::CUserManager::GetDisplayName ( )

Method used to retrieve the displayName given by the user at creation time or by a call to SetProfile.

Returns
is a C string holding the pseudo value.
const char* CloudBuilder::CUserManager::GetGamerID ( )

Method used to retrieve the GamerID.

Returns
is a C string holding the gamer ID value.
void CloudBuilder::CUserManager::GetGodchildren ( CResultHandler aHandler,
const char *  aDomain = "private" 
)

Method used to retrieve all the godchildren for the currently logged in user.

Parameters
aHandlerresult handler whenever the call finishes (it might also be synchronous)
aDomainis the domain in which the godfather link should be established. "private" means it's local to this game only.
Returns
if enNoErr is sent back to your handler, the "result" of the embedded JSON will have a value which may contain: { "godchildren" : [ { "gamer_id" : "xxx", "profile" :CotC Profile JSON }, ..... ] }
void CloudBuilder::CUserManager::GetGodfather ( CResultHandler aHandler,
const char *  aDomain = "private" 
)

Method used to retrieve the godfather of the currently logged in user.

Parameters
aHandlerresult handler whenever the call finishes (it might also be synchronous)
aDomainis the domain in which the godfather link should be established. "private" means it's local to this game only.
Returns
if enNoErr is sent back to your handler, the "result" of the embedded JSON will have a value which may contain: { "godfather" : { "gamer_id" : "xxx", "profile" : { CotC Profile JSON } }
void CloudBuilder::CUserManager::GetGodfatherCode ( CResultHandler aHandler,
const char *  aDomain = "private" 
)

Method to call in order to generate a temporary code that can be used to obtain a new godchild.

Parameters
aHandlerresult handler whenever the call finishes (it might also be synchronous)
aDomainis the domain in which the godfather link should be established. "private" means it's local to this game only.
Returns
if enNoErr is sent back to your handler, the "result" of the embedded JSON will have a value which may contain: { "godfathercode" : "xxx" }
const char* CloudBuilder::CUserManager::GetMail ( )

Method used to retrieve the email address given by the user at creation time or by a call to SetProfile .

Returns
is a C string holding the email address value.
static CUserManager* CloudBuilder::CUserManager::Instance ( )
static

Use this method to obtain a reference to the CUserManager.

Returns
the one and only instance of this manager
void CloudBuilder::CUserManager::ListAchievements ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Fetches information about the status of the achievements configured for this game. Additional configuration can be provided in the form of JSON data.

Parameters
aConfigurationJSON data
  • domain: the domain on which to list achievements (if none, uses the private one)
aHandlerresult handler, which will receiving the following data:
Returns
if noErr, the json passed to the handler may contain the following:
"achievements": {
"achievementName": {
"type": "limit",
"config": {
"maxValue": 10,
"maxTriggerCount": -1,
"unit": "b",
"rewardTx": {
"b": "-auto",
"a": 10
}
},
"progress": 0
}
}
So you may use the following code to check the progress of a given achievement:
void ResultHandler(eErrorCode code, const CCloudResult *result) {
float progress = result->GetJSON()->GetSafe("achievements")->GetSafe("achievementName")->GetFloat("progress");
}
void CloudBuilder::CUserManager::Outline ( CResultHandler aHandler)

Method used to retrieve global user information, including profile, friends, devices, ... It's the same JSON as the one received upon the Login/ResumeSession process.

Parameters
aHandlerresult handler whenever the call finishes (it might also be synchronous)
void CloudBuilder::CUserManager::Publish ( const char *  aNetwork,
const CotCHelpers::CHJSON aMessage,
CResultHandler aHandler 
)

If the user is logged in with a Facebook linked account, you can use this method to publish something on this user's wall.

Parameters
aNetworkis the external social network on which the message should be published.
aMessageis a JSON object containing the message to be published on the wall. If the JSON object contains only one key, then the value has to be a string, and this string will be published to the wall, without any interaction with the user. Otherwise, the FB Share Dialog is presented to the user for confirmation and the JSON object should contain the following keys: 'link' : URL (http/https only) 'name' : title 'body' : message body 'picture' : image url (http/https only)
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if enNoErr is sent back to your handler, the "result" of the embedded JSON may contain:
"done": "1"
This is 1 if the story has effectively been published, 0 otherwise.
void CloudBuilder::CUserManager::RegisterForNotification ( )

Method used to signal that the currently logged in user is ready to receive push notifications. Usually, this is called internally by CotC at login time, unless CClan::Setup has been called with an option to delay the registration.

void CloudBuilder::CUserManager::SetAchievementData ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Allows to store arbitrary data for a given achievement and the current player (appears in the 'gamerData' node of achievements).

Parameters
aConfigurationJSON data describing the operation to perform
  • domain: domain identifying the achievement
  • name: name of the achievement
  • data: data to set (freeform)
aHandlerthe handler called with the result when the call completes
Returns
if noErr, the json passed to the handler will contain the updated definition of the achievement
void CloudBuilder::CUserManager::SetGodfather ( const char *  aCode,
const CotCHelpers::CHJSON aOptions,
CResultHandler aHandler 
)

Method to call to attribute a godfather to the currently logged in user.

Parameters
aCodeis a string as generated by ::GetGodfatherCode.
aOptionsis a JSON object containing optionnal information. The JSON object may contains the following keys: 'maturity' : integer, age in number of days of the godchildren. (since the register date), if maturity is 0 or missing, no checks are made. 'domain' : "private" or the wanted domain 'reward' : a transaction Json rewarding the godfather formed as { transaction : { "unit" : amount}, description : "reward transaction", domain : "com.clanoftcloud.text.DOMAIN" } where desciption and domain are optionnals 'osn' : {"en" : "You've been rewarded"} if you want an OS notification for the godfather app NB : the godfather will reveive an event of type 'godchildren' containing the id of the godchildren and the balace/achievements field if rewarded
aHandlerresult handler whenever the call finishes (it might also be synchronous)
Returns
if enNoErr is sent back to your handler, the "result" of the embedded JSON may contain: { "done" : "1", }
void CloudBuilder::CUserManager::TransactionExtended ( const CotCHelpers::CHJSON aConfiguration,
CResultHandler aHandler 
)

Method to send a transaction for this user.

Parameters
aConfigurationthe JSON describing the configuration, which may include:
  • 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 in CUserManager::Transaction
  • description: a string describing the transaction
aHandlerthe handler called with the result when the call completes
Returns
if noErr, a JSON which may contain the following:
"balance": {
"Gold" : 100,
"Silver" : 10
},
"achievements": [
{
"name": "test",
"type": "limit",
"config": {
"type": "limit",
"maxValue": 1000,
"unit": "score"
}
}
]
}

The documentation for this class was generated from the following file: