Using awPublishRequestAndWait
After the preliminary processing described in
The Requestor has been completed, the callback approach involves the following steps:
1. Use awRegisterCallback to register a general callback.
2. Use awPublishRequestAndWait to publish the request and wait for the reply.
Note:
No event subscription is necessary in this model because the awPublishRequestAndWait function requires that the reply event be delivered, not published
The following example shows how you can awPublishRequestAndWait:
. . .
BrokerBoolean test_callback1(BrokerClient c, BrokerEvent e,void *data);
int main(int argc, char **argv)
{
BrokerClient c;
BrokerEvent e;
BrokerEvent *events;
long n;
. . .
/* Register general callback */
err = awRegisterCallback(c,test_callback1,"general");
/* check for errors */
. . .
err = awPublishRequestAndWait(c, e, 6000, &n, &events);
/* check for errors */
. . .
/* Process received events */
for( i = 0; i < n; i++) {
if (awIsNullReplyEvent(events[n])) {
printf("Null reply received.\n");
} else if (awIsErrorReplyEvent(events[n])) {
printf("Error reply received.\n");
} else {
/* process the event */
. . .
}
awDeleteEvent(events[n]);
}
free(events);
. . .