Client
The BrainCloudClient class is the core of the brainCloud API. From the BrainCloudClient you can access all of brainCloud's services (Authentication, Entity, etc) and from there the individual API's they contain.
The Client also contains many setup and configuration methods for timeouts, global callbacks, and more.
API Summary
Critical
Functions that are necessary to use the brianCloud library.
Callbacks
Functions to register and deregister callbacks for specific events.
Timeouts
Functions to configure network timeouts.
- SetPacketTimeoutsToDefault
- GetPacketTimeouts
- SetPacketTimeouts
- GetAuthenticationPacketTimeout
- SetAuthenticationPacketTimeout
Status
Functions to query the client state or reset network communications.
- IsAuthenticated
- IsInitialized
- GetSessionId
- ResetCommunication
- InsertEndOfMessageBundleMarker
- OverrideCountryCode
- OverrideLanguageCode
- EnableLogging
File Upload
Functions to register for file upload callbacks and configure upload specific timeouts.
- RegisterFileUploadCallback
- DeregisterFileUploadCallback
- GetUploadLowTransferRateThreshold
- SetUploadLowTransferRateThreshold
- GetUploadLowTransferRateTimeout
- SetUploadLowTransferRateTimeout
Network Error Caching
Functions to enable and manage network error message caching.
Global Error Logging
Functions to register and deregister callbacks for all error events.
Compatibility
Compatibility settings for older brainCloud versions.
📄️ DeregisterEventCallback
Deregisters the event callback.
📄️ DeregisterFileUploadCallback
Deregisters the file upload callback
📄️ DeregisterGlobalErrorCallback
Deregisters the global error callback.
📄️ DeregisterNetworkErrorCallback
Deregisters the network error callback.
📄️ DeregisterRewardCallback
Deregisters the event callback.
📄️ EnableCompressedRequests
Enables sending Gzip compressed packets of requests from client side. Which can significantely decrease response time for requests with large body content.
📄️ EnableCompressedResponses
Enables receiving compressed packets of responses.
📄️ EnableLogging
Enables console logging of outgoing/incoming packets and other informational logs from the client.
📄️ EnableNetworkErrorMessageCaching
Enables the timeout message caching which is disabled by default. Once enabled, if a client side timeout is encountered (i.e. server is unreachable presumably due to the client network being down) the SDK will do the following:
📄️ FlushCachedMessages
Flushes the cached messages to resume API call processing. This will dump all of the cached messages in the queue.
📄️ GetAppId
Returns the app id of the client app.
📄️ GetAppVersion
Returns the app version of the client app.
📄️ GetAuthenticationPacketTimeout
Gets the authentication packet timeout which is tracked separately from all other packets. Note that authentication packets are never retried and so this value represents the total time a client would wait to receive a reply to an authentication API call.
📄️ GetPacketTimeouts
Returns the list of packet timeouts.
📄️ GetSessionId
Returns the session id if a connection with has been established.
📄️ GetUploadLowTransferRateThreshold
Returns the low transfer rate threshold in bytes/sec.
📄️ GetUploadLowTransferRateTimeout
Returns the low transfer rate timeout in seconds.
📄️ Initialize
To initialize, use this code:
📄️ InitializeIdentity
Initializes the authentication service with an anonymous installation ID and most recently used profile ID.
📄️ InsertEndOfMessageBundleMarker
Inserts a marker which will tell the comms layer to close the message bundle off at this point. Any messages queued before this method was called will likely be bundled together in the next send to the server.
📄️ IsAuthenticated
Returns true if the user is authenticated.
📄️ IsInitialized
Returns whether the has been initialized using the Initialize() method.
📄️ OverrideCountryCode
Sets the country code sent to when a user authenticates. Will override any auto detected country.
📄️ OverrideLanguageCode
Sets the language code sent to when a user authenticates. If the language is set to a non-ISO 639-1 standard value the app default will be used instead. The supported languages and the default can be set on the Localization page of the portal.
📄️ RegisterEventCallback
This method is now deprecated. For real-time events, you should use the RTT API method, RegisterRTTEventCallback(), instead.
📄️ RegisterFileUploadCallback
Registers the file upload callbacks.
📄️ RegisterGlobalErrorCallback
Registers the Global Error callbacks.
📄️ RegisterNetworkErrorCallback
Registers a callback that is invoked for network errors. Note this is only called if EnableNetworkErrorMessageCaching has been set to true.
📄️ RegisterRewardCallback
Sets a reward handler for any API call results that return rewards.
📄️ ResetCommunication
Clears any pending messages from communication library and clears all session information.
📄️ RetryCachedMessages
Attempts to resend any cached messages. If no messages are in the cache, this method does nothing.
📄️ RunCallbacks
Run callbacks, to be called once per frame from your main thread
📄️ SetAuthenticationPacketTimeout
Sets the authentication packet timeout which is tracked separately from all other packets. Note that authentication packets are never retried and so this value represents the total time a client would
📄️ SetErrorCallbackOn202Status
Sets whether the error callback is triggered when a 202 status is received from the server. By default this is true.
📄️ SetOldStyleStatusMessageErrorCallback
Sets the error callback to return the status message instead of the error JSON string. This flag is used to conform to pre-2.17 client
📄️ SetPacketTimeouts
Sets the packet timeouts using a list of integers that represent timeout values in seconds for each packet retry. The first item in the list represents the timeout for the first packet attempt, the second for the second packet attempt, and so on.
📄️ SetPacketTimeoutsToDefault
Sets the packet timeouts back to default.
📄️ SetUploadLowTransferRateThreshold
Sets the low transfer rate threshold of an upload in bytes/sec.
📄️ SetUploadLowTransferRateTimeout
Sets the timeout in seconds of a low speed upload (ie transfer rate which is underneath the low transfer rate threshold).
📄️ ShutDown
Shuts down all systems needed for BrainCloudClient, only call this from the main thread. Should be used at the end of the app, and opposite of Initialize Client.
📄️ Update
Update method needs to be called regularly in order to process incoming and outgoing messages.