Previous PageTable Of ContentsIndexNext Page



Description

Returns an event buffer to the AG ISDN API.

Prototype

DWORD isdnReleaseBuffer ( CTAHD ctahd,
void
*buffer )

ctahd CTA context handle associated with a D channel, returned by ctaCreateContext or adiOpenPort.

buffer Pointer to the event buffer.

Return Values

SUCCESS

CTAERR_INVALID_CTAHD
The CTA context handle is invalid.

CTAERR_INVALID_STATE
An ISDN protocol stack instance is not started on the specified CTA context, or an instance is starting or stopping on the CTA context.

ISDNERR_INVALID_BUFFER
The buffer submitted is not a valid buffer.

Events

None.

Details

This function indicates to the ACU that the application has finished processing an event buffer (described by the CTA_EVENT buffer and size fields) and is returning that buffer to the AG ISDN API. The event ID for ISDN events is ISDNEVN_RCV_MESSAGE.

    Note: The application must return every event buffer to the AG ISDN API as soon as possible, or the API will time out and stop passing events to the application.

Example

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 asynchnous 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;
}
...
}


Natural MicroSystems, Inc.
100 Crossing Boulevard
Framingham, MA 01702

Contact Developer Support

Previous PageTable Of ContentsIndexNext Page