Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
BackendCallback Class Reference
Inheritance diagram for BackendCallback:
SCR_BackendCallbackRoomMods SCR_RoomCallback SCR_WorkshopItemCallback_AskDetails SCR_WorkshopItemCallback_DownloadImage

Detailed Description

Object used as callback structure in which you will receive results of Backend requests exposed via ScriptAPIs.

For callback function you can use any function without arguments or with BackendCallback as the only argument. If BackendCallback was provided as the argument it will contain BackendCallback used for the request that invoked it. Allowed arguments of the function can be found in typedef of BackendCallbackFunc.

Warning
Callback has to be preserved until it receives response. If it is deleted before it finishes then request will be automatically killed. If callback is not stored as ref then it will be deleted after its execution finishes.
Note
Timeouts of native Backend requests should be generally considered and handled same as an error. But if required it can be differentiated via GetRestResult() == ERestResult.EREST_ERROR_TIMEOUT

Examples of callback functions:

// you can use function without arguments
void MyOnSuccessFunction()
{
// This code will be executed on successful request
}
// or add BackendCallback argument
void MyOnSuccessFunction(BackendCallback cb)
{
// This code will be executed on successful request
// you can access specific API code for special behavior
EApiCode apiCode = cb.GetApiCode();
// you can access HTTP result code as enum
HttpCode httpResultEnum = cb.GetHttpCode();
}
// use different function for error event
void MyOnErrorFunction(BackendCallback cb)
{
// This code will be executed if request failed
// you can access API code provided by backend in case of error
EApiCode apiCode = cb.GetApiCode();
// you can store HTTP code as int for codes undefined in HttpCode enum
int httpResultInt = cb.GetHttpCode();
}
EApiCode
Definition EApiCode.c:13
HttpCode
Definition HttpCode.c:19

You have to set functions on the BackendCallback instance for them to be invoked:

m_MyCallback = new BackendCallback();
m_MyCallback.SetOnSuccess(MyOnSuccessFunction);
m_MyCallback.SetOnError(MyOnErrorFunction);

Definition at line 4 of file Backend_Storage.c.


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