Returns an event buffer to the NMS ISDN API.
DWORD isdnReleaseBuffer ( CTAHD ctahd, void *buffer)
Argument |
Description |
ctahd |
Context handle associated with a D channel, returned by ctaCreateContext. |
buffer |
Pointer to the event buffer. |
Return value |
Description |
SUCCESS |
|
CTAERR_INVALID_CTAHD |
The context handle is invalid. |
CTAERR_INVALID_STATE |
An ISDN protocol stack instance is not started on the specified context, or an instance is starting or stopping on the context. |
ISDNERR_INVALID_BUFFER |
The buffer submitted is not valid. |
None.
This function informs the stack that the application has finished processing an event buffer (described by the CTA_EVENT buffer and size fields) and is returning the buffer to the NMS ISDN API. The event ID for ISDN events is ISDNEVN_RCV_MESSAGE.
The application must return every event buffer to the NMS ISDN API as soon as possible, or the API times out and stops passing events to the application.
DWORD sample_process_events (CTAHD ctahd)
{
CTA_EVENT event;
ISDN_MESSAGE *imsg;
ISDN_PACKET *ipkt;
BYTE *data;
DWORD ret;
char errortext[40];
#define EVENT_CODE(from, code) ((from<<8)|code)
...
/*
** Protocol already started...
** Application may have sent messages to stack
*/
...
/*
** Application waiting for events
*/
myWaitForEvent( ctahd, &event);
/*
** Got event ISDN_RCV_MESSAGE
** If the event value field is not SUCCESS, then
** the event was not received successfully.
*/
if( event.value != SUCCESS )
{
ctaGetText(ctahd, event.value, errortext, 40);
printf("RCV_FAIL: %s\n", errortext);
return MY_ERROR_RCV_FAILED;
}
/*
** NOTE: all asynchronous events have the
** msg->userid field is ISDN_USERID_ASYNC
*/
ipkt = (ISDN_PACKET *) event->buffer;
imsg = &ipkt->message;
data = ipkt->data;
printf("from: %c code=%c to=%c id=%d len=%d\n",
imsg->from_ent,
imsg->code,
imsg->to_ent,
imsg->add.conn_id,
ipkt->data_len);
switch(EVENT_CODE(imsg->from_ent, imsg->code) )
{
case EVENT_CODE(ENT_ACU, CONN_CO):
/*
** Call is now connected
*/
printf("Connected on conn_id: %d\n",imsg->add.conn_id);
break;
case EVENT_CODE(ENT_ACU,ACU_CLEAR_CO):
/*
** Call is now cleared
*/
printf("Cleared on conn_id: %d\n", imsg->add.conn_id);
break;
...
default:
printf("Unprocessed message: %c %c\n", imsg->from_ent,
imsg->code);
break;
}
/*
** Processing is done, release the buffer as soon as possible
*/
ret = isdnReleaseBuffer( ctahd, event.buffer );
if( ret != SUCCESS )
{
ctaGetText(ctahd, event.value, errortext, 40);
printf("RELEASE_FAIL: %s\n", errortext);
return MY_ERROR_RELEASE_FAILED;
}
...
}