
Description | Cautions | Example | Errors | See Also
Name: |
long sr_putevt(dev, evttype, evtlen, evtdatap, errcode) | |
Inputs: |
long dev |
|
|
unsigned long evttype |
|
|
long evtlen |
|
|
void *evtdatap |
|
|
long errcode |
|
Returns: |
0 if successful | |
|
-1 if error | |
|
||
Includes: |
srllib.h | |
|
dxxxlib.h | |
Type: |
Event Management function | |
Mode: |
Synchronous | |
The sr_putevt( ) function allows the application to add an event to the SRL event queue within the same process. If event data is to be passed through the evtdatap parameter, the evtlen parameter should be set to its corresponding length. The SRL makes of a copy of the user's data that is pointed to by the evtdatap parameter. Therefore, the caller can dispose of the event data immediately after calling the sr_putevt( ) function. The function parameters are described as follows:
Parameter |
Description |
dev |
Valid device handle of the device opened through either setting the dev parameter to SRL_DEVICE or calling one of the xx_open( ) functions. Use the sr_getevtdev( ) function to retrieve this value when an event occurs. |
evttype |
User-supplied event type. This can be any unique event number. Use the sr_getevttype( ) function to retrieve this value when an event occurs. |
evtlen |
Length of variable-length data associated with the event. Use the sr_getevtlen( ) function to retrieve this value when the event occurs. If no data is associated with an event, set evtlen to zero, and set the evtdatap parameter to NULL. |
evtdatap |
Pointer to the variable-length data of the size in the evtlen parameter. The SRL makes a copy of this data and attaches it to the event. The sr_getevtdatap( ) function returns a pointer to the memory containing the variable-length information. If no data is associated with an event, set this parameter to NULL, and set the evtlen parameter to zero. |
errcode |
Specifies an error code that can be set when the event is posted. Calling the ATDV_LASTERR( ) function on the device handle on which the event is posted returns this error. Set to zero if no error is to be reported on this device. If non-zero, you can use the ATDV_LASTERR( ) function on this device to retrieve the error. |
Use either the sr_waitevt( ) function or the sr_waitevt(Ex) function to retrieve the events generated by the sr_putevt( ) function. The sr_putevt( ) function can also unblock synchronous functions that are blocked waiting for certain events. For example, if a Voice library dx_getevt( ) or dx_wtring( ) function is waiting for CST events to be posted to the queue, you can simulate incoming calls by posting TDX_CST events to the queue.
This function fails if you specify an invalid device handle.
#include <windows.h>
#include <srllib.h> #include <dxxxlib.h> int dev; /* Dialogic device handle */ DX_CST cst; /* TDX_CST event data block */ /* Open board 1 channel 1 device */ if ((dev = dx_open("dxxxB1C1", 0)) == -1) { printf("Cannot open channel dxxxB1C1"); exit(1); } /* Simulate an incoming call */ cst.cst_event = DE_RINGS; cst.cst_data = 0; /* Put the event on the event queue */ if (sr_putevt(dev, TDX_CST, sizeof(DX_CST), &cst, 0) != SR_SUCCESS) { printf("_sr_putevt failed - %s", ATDV_ERRMSGP(SRL_DEVICE))); . . . }
The sr_putevt( ) function returns SR_NOMEM if memory cannot be allocated to store the event on the SRL event queue.
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation