I recently got the CTI License installed on my Avaya IP Office 500, and installed the devlink sdk. I have read the developers manual and put together a test application. I can connect to the IP Office with the DLOpen() function, but when I call the DLRegisterType2CallDeltas() function the program stops at this point and I do not receive any events. My code is:
#include <windows.h>
#include <iostream>
#include "conio.h"
#include "devlink.h"
using namespace std;
HANDLE hEvent;
DWORD dwCommsEvent;
BOOL bStarting;
void CALLBACK HandleCallLogEvent(DWORD pbxh, TEXT * info) {
cout << "A Call Event has occurred..." << endl;
cout << "info is " << info << endl;
}
void CALLBACK HandleCommsEvent( DWORD pbxh, DWORD comms_evt, DWORD parm1 ) {
cout << "starting CALLBACK HandleCommsEvent..." << endl;
switch( comms_evt ) {
case DEVLINK_COMMS_OPERATIONAL:
cout << "Got comms operational message" << endl;
// we are working fine... fall through
case DEVLINK_COMMS_NORESPONSE:
// system not found (initial connection),
// or network connection lost (rebooted?)
// fall through...
case DEVLINK_COMMS_REJECTED:
// incorrect system password specified...
if( bStarting ) {
dwCommsEvent = comms_evt;
SetEvent( hEvent );
}
else {
// insert your code here...
}
break;
case DEVLINK_COMMS_MISSEDPACKETS:
// Indicates that the system is under
// heavy load. IP Office always prioritises
// data routing and call handling above CTI events.
// (parm1 contains the number of packets missed)
break;
}
}
int main(int argc, char* argv[]) {
int i = 0;
long res;
cout<< "connecting..." << endl;
bStarting = TRUE;
hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
DLOpen( 1,
"10.120.4.4",
"password",
NULL,
NULL,
HandleCommsEvent );
dwCommsEvent = DEVLINK_COMMS_NORESPONSE;
WaitForSingleObject( hEvent, 20000 ); // 20 seconds
bStarting = FALSE;
if( dwCommsEvent == DEVLINK_COMMS_OPERATIONAL ) {
cout << "Connected OK" << endl;
for (i=0; i<20; i++) {
cout << "waiting for event[" << i << "]" << endl;
res = DLRegisterType2CallDeltas( 1, HandleCallLogEvent );
switch(res) {
case DEVLINK_SUCCESS:
cout << "Event successful!" << endl;
break;
case DEVLINK_UNSPECIFIEDFAIL:
cout << "Event result is unspecified error" << endl;
break;
case DEVLINK_LICENCENOTFOUND:
cout << "No CTI license for Events on IP Office" << endl;
}
}
}
else {
cout << "Error connecting to IP Office" << endl;
}
DLClose( 1 );
CloseHandle( hEvent );
_getch();
return 0;
}
Console output:
connecting...
starting CALLBACK HandleCommsEvent...
Got comms operational message
Connected OK
waiting for event[0]
(at this point nothing further happens as it waits for an event to return)
Any input on what I have done wrong or links to example code beyond what is in the developer's guide would be great. I am using Visual C++ Express 2012 as the compiler.
Thanks,
Dave
|