Vp callback set: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
|paramex=callbackname, callback | |paramex=callbackname, callback | ||
|parameters= | |parameters= | ||
{{sdk parameter row|vp_callback_t |callbackname|Callback to set handler for}} | {{sdk parameter row|vp_callback_t |callbackname|[[:Category:SDK callbacks|Callback]] to set handler for}} | ||
{{sdk parameter row|VPCallbackHandler|callback |Callback handler}} | {{sdk parameter row|VPCallbackHandler|callback |Callback handler}} | ||
|returncodes= | |returncodes= | ||
|behavior= | |behavior= | ||
|caveats= | |caveats= | ||
Line 21: | Line 20: | ||
//... | //... | ||
vp_callback_set(sdk, VP_CALLBACK_LOGIN); | vp_callback_set(sdk, VP_CALLBACK_LOGIN, handle_login); | ||
if (rc = | if (rc = vp_login(sdk, Username, Password, Botname)) | ||
{ | { | ||
printf("Couldn't login (reason %d)", rc); | printf("Couldn't login (reason %d)", rc); | ||
Line 33: | Line 32: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|seealso= | |seealso= | ||
}} | }} |
Latest revision as of 22:01, 13 December 2016
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;
}
//...
}