vp_callback_set

From Virtual Paradise Wiki
Revision as of 22:01, 13 December 2016 by Sleepy E (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;
  }

  //...
}