为什么未调用我的delta2回调函数?

时间:2019-04-22 22:28:04

标签: c++ visual-studio visual-c++ avaya

我正在尝试使我的devlink C ++示例与我的AVAYA IP500一起使用,并且连接似乎正常工作,DLOpen函数运行良好,并且回调函数也被调用,但是当我调用DLRegisterType2CallDeltas获取事件日志时,它将返回0(DEVLINK_SUCCESS),并且永远不会调用回调函数。

如您所见,控制台中从不显示消息“已检测到事件”,我也在该行中设置了断点,而没有任何操作。

我具有有效的CTI Pro许可证,并配置了我的PC TAPI服务提供商

请帮助。

这是devlink.h代码

#ifndef _DEVLINK_H_ 
#define _DEVLINK_H_ 

typedef char TEXT;

#define DEVLINK_SUCCESS             0 
#define DEVLINK_UNSPECIFIEDFAIL     1 
#define DEVLINK_LICENCENOTFOUND     2 

#define DEVLINK_COMMS_OPERATIONAL 0 
#define DEVLINK_COMMS_NORESPONSE  1 
#define DEVLINK_COMMS_REJECTED    2 
#define DEVLINK_COMMS_MISSEDPACKETS 3 

#ifdef __cplusplus 
extern "C"
{
#endif 

    typedef void (CALLBACK * DLCALLLOGEVENT)(
        DWORD   pbxh,
        TEXT   * info
        );

    typedef void (CALLBACK * DLCOMMSEVENT)(
        DWORD   pbxh,
        DWORD    comms_state,
        DWORD    parm1
        );

    LONG  PASCAL  DLOpen(DWORD pbxh
        , TEXT * pbx_address
        , TEXT * pbx_password
        , TEXT * reserved1
        , TEXT * reserved2
        , DLCOMMSEVENT cb
    );
    LONG  PASCAL  DLClose(DWORD pbxh);

    LONG  PASCAL  DLRegisterType2CallDeltas(DWORD  pbxh, DLCALLLOGEVENT cb);

#ifdef __cplusplus 
};
#endif 

#endif // _DEVLINK_H_ 

这是我的主要代码

#include "pch.h"
#include <windows.h>
#include <stdio.h>
#include "devlink.h"

HANDLE hEvent;
DWORD dwCommsEvent;
BOOL bStarting;

void CALLBACK HandleDelta2Event(DWORD pbxh, char* switchInfo)
{
    printf("An event has been detected\n");
}

void CALLBACK HandleCommsEvent(DWORD pbxh, DWORD comms_evt, DWORD parm1)
{
    printf("event: %d - %d\n", comms_evt, parm1);
    switch (comms_evt)
    {
    case DEVLINK_COMMS_OPERATIONAL:
        // 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 speciffied   

        if (bStarting)
        {
            dwCommsEvent = comms_evt;
            SetEvent(hEvent);
        }
        else
        {
        }
        break;

    case DEVLINK_COMMS_MISSEDPACKETS:
        // Indicates that system is under heavy load.   
        // IP Office always priorities data routing   
        // and call handling above CTI events   
        // (parm1 contains nnumber of packets missed)   
        break;
    }
}

int main(int argc, char* argv[])
{
    bool enter = false;
    long res;
    printf("connecting...");
    bStarting = TRUE;
    hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    char swp[] = "[My IP500 IP]";
    char pw[] = "[Security user password]";
    DLOpen(0, swp, pw, NULL, NULL, HandleCommsEvent);
    dwCommsEvent = DEVLINK_COMMS_NORESPONSE;
    WaitForSingleObject(hEvent, 10000); // 10 seconds
    bStarting = FALSE;
    if (dwCommsEvent == DEVLINK_COMMS_OPERATIONAL)
    {
        printf("Connected OK\n");
        printf("Waiting for event\n");
        while (!enter)
        {
            res = DLRegisterType2CallDeltas(0, HandleDelta2Event);
            printf("Code: %d\n", res);
        }
    }
    else
    {
        printf("Error connecting to IP Office\n");
    }
    DLClose(0);
    CloseHandle(hEvent);
    return 0;
}

我的输出如下所示

connecting...event:0 - 0
event: 3 - -1
Connected OK
Waiting for event
code: 0
code: 0
code: 0
code: 0
code: 0
... keeps forever
event: 1 - 0
event: 0 - 0
event: 3 - -1
code: 0
code: 0
code: 0
code: 0
code: 0
... keeps forever

0 个答案:

没有答案
相关问题