This tutorial goes over the basics of using brainCloud in C#. This applies to .NET applications, Xamarin, and even Unity.
All of brainCloud’s features are accessible through the BrainCloudClient class. Typically you will only ever need one instance of the BrainCloudClient in your application. For this reason the BrainCloudClient can function as a singleton, and can be accessed through the BrainCloudClient.Instance property.
Before you can do anything with brainCloud the BrainCloudClient must be initialized. This is accomplished by providing your App’s details to the Client via the Initialize function.
Updating the Client
To ensure callbacks are executed on the main thread you must call the Update method of the BrainCloudClient. Typically you will want to set up some version of an Update loop in your app that will constantly update the client every so often (ex. every 100ms).
Once a method is in place to run the callbacks via the Update() method you can start making API calls. The first call you’ll likely need to make is to one of the authentication methods to get an active session.
All API methods in brainCloud that contact the brainCloud server take callbacks as parameters, one for success and one for failure. These will get called when a response is received from the server, or the request times out. Here is a simple example of the authentication process in a console application:
// Get username
Console.WriteLine("Enter your username: ");
string username = Console.ReadLine();
// Get password
Console.WriteLine("Enter your password: ");
string password = Console.ReadLine();
private void ApiSuccess(string jsonResponse, object cb)
private void ApiError(int statusCode, int reasonCode, string statusMessage, object cb)