vp_callback_set

From Virtual Paradise Wiki
Jump to navigation Jump to search
Method call snippet vp_callback_set(instance, callbackname, callback);

Sets handler for a specific callback.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
vp_callback_t
callbackname
Callback to set handler for
VPCallbackHandler
callback
Callback handler

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)

Behavior

There is no special behavior for this method

Examples

void handle_login(VPInstance sdk, int rc, int ref)
{
  if (rc)
    printf("Error logging into universe (reason %d)\n", rc);
}

int main(int argc, const char* argv[])
{

  //...

  vp_callback_set(sdk, VP_CALLBACK_LOGIN, handle_login);

  if (rc = vp_login(sdk, Username, Password, Botname))
  {
    printf("Couldn't login (reason %d)", rc);
    return 1;
  }

  //...
}