
Description | Termination Events | Cautions | Example | Errors | See Also
Name: |
int cl_GetTransaction(hDevice, pidTransaction, pclEventData) | |
Inputs: |
long hDevice |
|
long* pidTransaction |
| |
CL_EVENTDATA* pclEventData |
| |
Returns: |
0 on success | |
Includes: |
cllib.h | |
Mode: |
synchronous | |
The cl_GetTransaction( ) function returns the ID of a call logging transaction for which a CLEV_MESSAGE event was generated. The returned call logging transaction ID is unique and protocol dependent.
Parameter |
Description |
hDevice: |
The device handle of the call logging device. |
pidTransaction: |
The pointer to the returned call logging transaction ID. |
pclEventData: |
The pointer to the call logging event data block obtained from sr_getevtdatap( ) while the function was processing a CLEV_MESSAGE event. See Section 1.5.2. Retrieving Event Datafor more on the event data block. |
None
#include <srllib.h>
#include <cllib.h>
#include <stdio.h>
#include <malloc.h>
typedef struct
{
const char* pszProtocol;
const char* pszNetworkDeviceName;
const char* pszUserDeviceName;
} DEVICEUSRATTR;
typedef struct
{
time_t timeConnect;
time_t timeDisconnect;
} TRANSACTIONUSRATTR;
extern DEVICEUSRATTR* GetDeviceUsrAttr(long hDevice);
extern TRANSACTIONUSRATTR* GetTransactionUsrAttr(long hDevice, long idTransaction);
extern TRANSACTIONUSRATTR* SetTransactionUsrAttr(long hDevice, long idTransaction);
long EventHandler(unsigned long hEvent)
{
long hDevice;
long lEvent;
CL_EVENTDATA* pclEventData;
int iRet;
long idTransaction;
DEVICEUSRATTR* pDeviceUsrAttr;
TRANSACTIONUSRATTR* pTransactionUsrAttr;
hDevice = sr_getevtdev(hEvent);
if (hDevice == -1)
{
printf("EventHandler - sr_getevtdev() failed\n");
return 1;
}
lEvent = sr_getevttype(hEvent);
if (lEvent == -1)
{
printf("EventHandler - sr_getevttype() failed\n");
return 1;
}
pclEventData = (CL_EVENTDATA*)sr_getevtdatap(hEvent);
if (pclEventData == NULL)
{
printf("EventHandler - sr_getevtdatap() failed\n");
return 1;
}
pDeviceUsrAttr = GetDeviceUsrAttr(hDevice);
if (lEvent == CLEV_MESSAGE)
{
printf("EventHandler - CLEV_MESSAGE - iResult=%08X\n", pclEventData->iResult);
iRet = cl_GetTransaction(hDevice, &idTransaction, pclEventData);
if (iRet != 0)
{
if (iRet == -2)
{
printf("EventHandler - Transaction already released\n");
}
else
{
printf("EventHandler - cl_GetTransaction() failed\n");
}
return 0;
}
printf("Transaction ID=%08X\n", idTransaction);
if ((pclEventData->iResult & ECL_FIRST_MESSAGE) != 0)
{
pTransactionUsrAttr = SetTransactionUsrAttr(hDevice, idTransaction);
}
else
{
pTransactionUsrAttr = GetTransactionUsrAttr(hDevice, idTransaction);
}
if (pTransactionUsrAttr != NULL)
{
if ((pclEventData->iResult & ECL_CONNECT_MESSAGE) != 0)
{
pTransactionUsrAttr->timeConnect = pclEventData->timeEvent;
}
if ((pclEventData->iResult & ECL_DISCONNECT_MESSAGE) != 0)
{
pTransactionUsrAttr->timeDisconnect = pclEventData->timeEvent;
}
}
if ((pclEventData->iResult & ECL_LAST_MESSAGE) != 0)
{
free(pTransactionUsrAttr);
pTransactionUsrAttr = NULL;
iRet = cl_ReleaseTransaction(hDevice, idTransaction);
if (iRet != 0)
{
if (iRet == -2)
{
printf("EventHandler - Transaction already released\n");
}
else
{
printf("EventHandler - cl_ReleaseTransaction() failed\n");
}
}
}
return 0;
}
else if (lEvent == CLEV_ALARM)
{
printf("EventHandler - CLEV_ALARM - iResult=%08X\n", pclEventData->iResult);
return 0;
}
else if (lEvent == CLEV_ERROR)
{
printf("EventHandler - CLEV_ERROR - iResult=%08X\n", pclEventData->iResult);
return 0;
}
printf("EventHandler - Unknown event(%08X)\n", lEvent);
return 1;
}
If the function returns a value < 0, use the SRL Standard Attribute function ATDV_LASTERR( ) to obtain the error code or use ATDV_ERRMSGP( ) to obtain a descriptive error message. The error codes that can be returned by ATDV_LASTERR( ) are:
Error Code Value |
Returned When |
ECL_NULLPARAMETER |
invalid NULL parameter |
ECL_INVALIDCONTEXT |
invalid event context |
ECL_TRANSACTIONRELEASED |
transaction already released |
ECL_INTERNAL |
internal Call Logging error; cause unknown |
See 2.2 Error Handling for more information about what kinds of errors can cause these codes to be returned
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation