CloudBuilder C++ SDK  v3.0.0
Making social games is easy !
Public Member Functions | Static Public Member Functions | List of all members
CloudBuilder::CClan Class Reference

#include <CClan.h>

Public Member Functions

virtual ~CClan ()
 
bool isSetup ()
 
bool isUserLogged ()
 
void Setup (const CHJSON *aConfiguration, CResultHandler *handler)
 
void Suspend ()
 
void Resume ()
 
void Terminate ()
 
void Ping (CResultHandler *handler)
 
void HandleURL (const CHJSON *aOptions, CResultHandler *handler)
 
void ProcessIdleTasks ()
 
void SetHttpFailureCallback (CDelegate< void(CHttpFailureEventArgs &)> *aCallback)
 
void SetLogLevel (LOG_LEVEL logLevel)
 

Static Public Member Functions

static CClanInstance ()
 

Detailed Description

The CloudBuilder::CClan class is the most important class. This is your primary entry point in the CloudBuilder SDK. All the setup is done in this class.

Constructor & Destructor Documentation

◆ ~CClan()

virtual CloudBuilder::CClan::~CClan ( )
virtual

Destructor

Member Function Documentation

◆ HandleURL()

void CloudBuilder::CClan::HandleURL ( const CHJSON aOptions,
CResultHandler handler 
)

Method to handle launch app with url: used to connect with facebook and google Also used , in case the url match with "://cotc/", for sponsorship and anonymous login on a new device.

Parameters
aOptionsis a json containing field "url" with the url. On iOS, for GooglePlus, a field "source" must contains sourceApplication as defined in the method:
  • (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
handlerresult handler whenever the call finishes (it might also be synchronous)

◆ Instance()

static CClan* CloudBuilder::CClan::Instance ( )
static

Function which returns the only instance of this class.

Returns
is the only instance of the CClan class.

◆ isSetup()

bool CloudBuilder::CClan::isSetup ( )

Method to be called in order to know if the CloudBuilder SDK has been correctly setup or not.

Returns
is a boolean. True if setup is correct, false otherwise.

◆ isUserLogged()

bool CloudBuilder::CClan::isUserLogged ( )

Method to be called in order to know if the user is logged in or not.

Returns
is a boolean. True if user is logged in, false otherwise.

◆ Ping()

void CloudBuilder::CClan::Ping ( CResultHandler handler)

Method to ping the server For now it returns the server time in utc key.

◆ ProcessIdleTasks()

void CloudBuilder::CClan::ProcessIdleTasks ( )

Call this in your main loop when you are in an idle state. Allows to process some events and callbacks pending and run them in your main thread.

◆ Resume()

void CloudBuilder::CClan::Resume ( )

Method you must call when your application is going to the foreground, so we can ensure data integrity when the application is getting the focus again.

◆ SetHttpFailureCallback()

void CloudBuilder::CClan::SetHttpFailureCallback ( CDelegate< void(CHttpFailureEventArgs &)> *  aCallback)

When called once from your app, this function disables the default behavior of the HTTP layer (unless called back with a null parameter). That is, no more retry by default, no more "offline mode" with requests put in a pending state.

In this "mode", requests are still executed serially (meaning that any request – API call – that was issued later on is only executed after success or failure of the previous). However, in case of failure, the request is not re-attempted automatically, instead the callback is called. From this callback, you can decide to either retry the request later, or abort it. Aborting it has the effect of allowing the next request to proceed.

There is an exception with the domain event loop which is run once logged in. The behaviour of this loop cannot be altered, the callback is not called and the request will be retried anyway.

Also note that the callback is only invoked upon retriable error (network related). If the server returns a non-recoverable error code or there is an error with an argument, the API call will fail immediately.

Parameters
aCallbackthe callback to be called whenever a request fails. Unlike all other uses of the delegates, this one can be called multiple times. Memory is managed by the library, that is the callback is freed when not in use anymore (additional call to this method or Terminate).

◆ SetLogLevel()

void CloudBuilder::CClan::SetLogLevel ( LOG_LEVEL  logLevel)

Sets the logging level to be used for future calls. Note that this doesn't apply to all calls, some other calls related to native plugins may need their own setup in order to show a verbose output.

Parameters
logLevellogging level, DEBUG_LEVEL_WARNING by default.

◆ Setup()

void CloudBuilder::CClan::Setup ( const CHJSON aConfiguration,
CResultHandler handler 
)

This method is the first to call just after the constructor. This will prepare everything so you can make requests later.

Parameters
aConfigurationis a JSON object holding the necessary connection details. The mandatory keys are:
  • "key": string containing the community key.
  • "secret": string containing the community secret.
  • "env": string containing the environment. Currently, "sandbox" (testing environment) and "prod" (production environment) are supported.

The optional keys are:

  • "appFolder": used with the default CFileSystemHandler to set the folder in which the data will be saved. On Windows, it would be USERPROFILE%\AppData\Roaming\<appFolder>\.
  • "autoresume" : boolean to control if after a Setup the system has to proceed an automatic resumesession when possible.
  • "autoRegisterForNotification": by default, RegisterForNotification is called right after login. By setting this key to 'false', you can manage when you want to register for notifications by calling the CUserManager::RegisterForNotification at your convenience.
  • "connectTimeout": sets a custom timeout allowed when connecting to the servers. Defaults to 5.
  • "httpTimeout": sets a custom timeout for all requests. Defaults to no limit.
  • "eventLoopTimeout": sets a custom timeout for the long polling event loop. Should be used with care and set to a high value (at least 60). Defaults to 590.
  • "httpVerbose": set to true to output detailed information about the requests performed to CotC servers. Can be used for debugging, though it will pollute the logs very much.
    Parameters
    handlerresult handler whenever the call finishes (it might also be synchronous)
    Returns
    if noErr, the json passed to the handler may contain: { "_error" : 0}

◆ Suspend()

void CloudBuilder::CClan::Suspend ( )

Method you must call when your application is going to the background, so we can ensure data integrity when the application is not active.

◆ Terminate()

void CloudBuilder::CClan::Terminate ( )

Method to call before quitting the application, so the CloudBuilder can leave in a clean state. Warning: invalidates all pointers to objects returned by CloudBuilder as memory is freed, including those returned by Instance().


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