Enfusion Script API
Loading...
Searching...
No Matches
RestCallback Interface Reference

Object used as callback structure in which you will receive results of scripted RestAPI calls. More...

Inheritance diagram for RestCallback:
Managed

Public Member Functions

proto external void SetOnSuccess (RestCallbackFunc onSuccess)
 Sets function which will be invoked if request was successful.
 
proto external void SetOnError (RestCallbackFunc onError)
 Sets function which will be invoked if request failed due to some error.
 
proto external ERestResult GetRestResult ()
 Returns Rest result of the request.
 
proto external HttpCode GetHttpCode ()
 Returns HTTP code result of the request.
 
proto external string GetData ()
 Returns raw data received via response as string.
 
void OnSuccess (string data, int dataSize)
 OBSOLETE - WILL BE REMOVED! Use SetOnSuccess() to set callback function instead!
 
void OnError (int errorCode)
 OBSOLETE - WILL BE REMOVED! Use SetOnError() to set callback function instead!
 
void OnTimeout ()
 OBSOLETE - WILL BE REMOVED! Use SetOnError() to set callback function instead and check GetRestResult() == ERestResult.EREST_ERROR_TIMEOUT!
 
- Public Member Functions inherited from Managed
proto external ref Managed Clone ()
 Return shallow copy of object, or null if it is not allowed (not public constructor)
 

Detailed Description

Object used as callback structure in which you will receive results of scripted RestAPI calls.

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

Warning
If callback is not stored as ref then it will be deleted after its execution finishes.

Examples of callback functions:

// you can use function without arguments
void MyOnSuccessFunction()
{
// This code will be executed on successful request
}
// or add RestCallback argument
void MyOnSuccessFunction(RestCallback cb)
{
// This code will be executed on successful request
// you can access data from the response
string data = cb.GetData();
// you can access HTTP result code as enum
HttpCode httpResultEnum = cb.GetHttpCode();
// or it can be stored as int for codes undefined in enum
int httpResultInt = cb.GetHttpCode();
}
// use different function for error event
void MyOnErrorFunction(RestCallback cb)
{
// This code will be executed if request failed
if (cb.GetRestResult() == ERestResult.EREST_ERROR_TIMEOUT)
{
// Handle error caused by request timeout
}
// you can access data if any were provided by the RestApi
string data = cb.GetData()
}
ERestResult
States and result + error code produced by RestApi.
Definition ERestResult.c:14
HttpCode
Common HTTP (result / error) codes Can be used in code as constant values to easier find use of speci...
Definition HttpCode.c:19
Object used as callback structure in which you will receive results of scripted RestAPI calls.
Definition RestCallback.c:72
proto external string GetData()
Returns raw data received via response as string.
proto external ERestResult GetRestResult()
Returns Rest result of the request.
proto external HttpCode GetHttpCode()
Returns HTTP code result of the request.

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

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

Member Function Documentation

◆ GetData()

proto external string RestCallback.GetData ( )

Returns raw data received via response as string.

◆ GetHttpCode()

proto external HttpCode RestCallback.GetHttpCode ( )

Returns HTTP code result of the request.

◆ GetRestResult()

proto external ERestResult RestCallback.GetRestResult ( )

Returns Rest result of the request.

◆ OnError()

void RestCallback.OnError ( int errorCode)

OBSOLETE - WILL BE REMOVED! Use SetOnError() to set callback function instead!

◆ OnSuccess()

void RestCallback.OnSuccess ( string data,
int dataSize )

OBSOLETE - WILL BE REMOVED! Use SetOnSuccess() to set callback function instead!

◆ OnTimeout()

void RestCallback.OnTimeout ( )

OBSOLETE - WILL BE REMOVED! Use SetOnError() to set callback function instead and check GetRestResult() == ERestResult.EREST_ERROR_TIMEOUT!

◆ SetOnError()

proto external void RestCallback.SetOnError ( RestCallbackFunc onError)

Sets function which will be invoked if request failed due to some error.

Refer to RestCallbackFunc to see what arguments are required for the function.

◆ SetOnSuccess()

proto external void RestCallback.SetOnSuccess ( RestCallbackFunc onSuccess)

Sets function which will be invoked if request was successful.

Refer to RestCallbackFunc to see what arguments are required for the function.


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