Aw callback set

From ActiveWiki
Jump to: navigation, search


Minimum requirements
Added in version 2.1
SDKbuild 13


int aw_callback_set (AW_CALLBACK c, void (*callback) (int rc))

Description

Establishes a callback handler for an asynchronous call.

Callback

None (returns immediately)

Arguments

c
Callback (defined in Aw.h)
callback
Pointer to the callback handler. Setting it to NULL deactivates the callback.

Argument attributes

None

Return values

RC_SUCCESS
RC_NOT_INITIALIZED
RC_INVALID_ATTRIBUTE
Not a callback.

Returned attributes

None

Usage

void handle_citizen_result (int rc)
{
  if (rc != RC_SUCCESS)
    printf ("Citizen manipulation failed (reason %d)\n", rc);
  else
    puts ("Citizen manipulation succeeded");
}

void change_homepage (int citizen, char *url)
{
  int rc;
  
  rc = aw_citizen_attributes_by_number (citizen);
  if (rc != RC_SUCCESS) 
    printf ("Citizen #%d query failed (reason %d)\n", citizen, rc);
  else
  {
    aw_callback_set (AW_CALLBACK_CITIZEN_RESULT, handle_citizen_result);
    aw_string_set (AW_CITIZEN_URL, url);
    aw_citizen_change ();
  }
}

See also