Skip to main content
Version: SDK-5.9.6

Callback Method Pooling

Callback method pooling is a function to request a BACKND function to the server asynchronously, store the callback method in a separate queue when the server responds, and execute it in the main thread.

With this, you can access Unity's Monobehavior object even in the callback method of an asynchronous method.

1. Setting for SDK initialization

To use callback method pooling, you must set the useAsyncPoll parameter as true when initializing the BACKND SDK.

First way of initializing SDK

void Start()
{
var bro = Backend.Initialize(true); // Set useAsyncPoll parameter as true
if(bro.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
}

Second way of initializing SDK

void Start()
{
Backend.InitializeAsync(true, callback => {
if(callback.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
}); // Set useAsyncPoll parameter as true
}

2. Calling the pooling method

If you enable the pooling method function, the callback of an asynchronous method is stored in a separate queue instead of being executed in the asynchronous IO thread.
To execute the callback method stored in the queue, the following pooling method must be called regularly:

void Update()
{
Backend.AsyncPoll();
}

The following is recommended to call the pooling method regularly:

  • Declare the pooling method in Unity object of the Update method
  • Generate a coroutine that is called regularly and declare the pooling method within that coroutine
  • Create a separate method that is called regularly and declare the pooling method within that method

The following is not recommended to call the pooling method regularly:

  • Declare a recursive method, and declare the pooling method within that recursive method