TAPI_EVENT.TE_CALLINFOCHANGE事件从未发生

本文关键字:CALLINFOCHANGE EVENT TE TAPI 事件 | 更新日期: 2023-09-27 18:13:06

我的过滤器包含下面的所有内容。我想在接到电话的时候看到每一个活动。这些都发生了:

--- incoming call
callhub
callnotification
callstate
address
--- incoming call disconnected
callhub
callstate

我想获取来电显示。当线路连接到我的手机时,我可以看到来电显示。但它并没有触发TAPI_EVENT.TE_CALLINFOCHANGE事件。

        tapiObj.EventFilter = (int)(TAPI_EVENT.TE_ACDGROUP |
                                     TAPI_EVENT.TE_ADDRESSDEVSPECIFIC |
                                     TAPI_EVENT.TE_AGENT |
                                     TAPI_EVENT.TE_AGENTHANDLER |
                                     TAPI_EVENT.TE_AGENTSESSION |
                                     TAPI_EVENT.TE_ASRTERMINAL |
                                     TAPI_EVENT.TE_CALLHUB |
                                     TAPI_EVENT.TE_CALLMEDIA |
                                     TAPI_EVENT.TE_DIGITEVENT |
                                     TAPI_EVENT.TE_FILETERMINAL |
                                     TAPI_EVENT.TE_GATHERDIGITS |
                                     TAPI_EVENT.TE_GENERATEEVENT |
                                     TAPI_EVENT.TE_PHONEDEVSPECIFIC |
                                     TAPI_EVENT.TE_PHONEEVENT |
                                     TAPI_EVENT.TE_PRIVATE |
                                     TAPI_EVENT.TE_QOSEVENT |
                                     TAPI_EVENT.TE_QUEUE |
                                     TAPI_EVENT.TE_REQUEST |
                                     TAPI_EVENT.TE_TAPIOBJECT |
                                     TAPI_EVENT.TE_TONEEVENT |
                                     TAPI_EVENT.TE_TONETERMINAL |
                                     TAPI_EVENT.TE_TTSTERMINAL |
                                     TAPI_EVENT.TE_ADDRESS |
                                     TAPI_EVENT.TE_CALLINFOCHANGE |
                                     TAPI_EVENT.TE_CALLSTATE |
                                     TAPI_EVENT.TE_CALLNOTIFICATION);

TAPI_EVENT.TE_CALLINFOCHANGE事件从未发生

最近我在tapi上工作。这是示例代码。。。。。

 cn=new callnotification();
 tobj.ITTAPIEventNotification_Event_Event+= new 
 TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cn.Event);
  tobj.EventFilter = (int)(TAPI_EVENT.TE_CALLNOTIFICATION | TAPI_EVENT.TE_REQUEST | 
             TAPI_EVENT.TE_CALLINFOCHANGE |
                TAPI_EVENT.TE_DIGITEVENT|
                TAPI_EVENT.TE_PHONEEVENT|
                TAPI_EVENT.TE_CALLSTATE|
                TAPI_EVENT.TE_GENERATEEVENT|
                TAPI_EVENT.TE_CALLINFOCHANGE |TAPI_EVENT.TE_ADDRESS
                );

class callnotification:TAPI3Lib.ITTAPIEventNotification
{
    public delegate void listshow(string str);
    public listshow addtolist;
    string callerid;

    public void Event(TAPI3Lib.TAPI_EVENT te,object eobj)
    {
        switch(te)
        {
            case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
                TAPI3Lib.ITDigitDetectionEvent dd=(TAPI3Lib.ITDigitDetectionEvent)eobj;
                addtolist("Dialed digit"+dd.ToString());
                break;
            case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
                TAPI3Lib.ITDigitGenerationEvent dg=(TAPI3Lib.ITDigitGenerationEvent)eobj;
                MessageBox.Show("digit dialed!");
                addtolist("Dialed digit"+dg.ToString());
                break;
            case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
                addtolist("A phone event!");
                break;
            case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
                addtolist("Gather digit event!");
                break;
            case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
                TAPI3Lib.ITCallStateEvent a=(TAPI3Lib.ITCallStateEvent)eobj;
                TAPI3Lib.ITCallInfo b=a.Call;
                try
                {
                    callerid = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER);
                    addtolist("Successfully Disconnect");
                }
                catch (Exception e)
                {
                    addtolist(e.Message);
                }
            switch(b.CallState)
            {
                case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
                    addtolist("INPROGRESS" );  
                                            break;
                case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
                    addtolist("Disconnected");
                    break;
                case TAPI3Lib.CALL_STATE.CS_OFFERING:
                    addtolist("A party wants to communicate with you!");
                    break;
                case TAPI3Lib.CALL_STATE.CS_IDLE:
                    addtolist("Call is created!");
                    break;
            }
            break;
            case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION: 
                addtolist("call notification event has occured");
                 break;
        }
    }
}
Private Sub tapiGenerate_Event(ByVal sender As Object, _
       ByVal e As TapiDigitGenerationEventArgs) Handles MyTAPI.TE_GENERATEEVENT
        Label4.Text = "GENERATE EVENT"
    End Sub
Private Sub tapiSpecific_Event(ByVal sender As Object, _
  ByVal e As TapiAddressDeviceSpecificEventArgs) Handles MyTAPI.TE_ADDRESSDEVSPECIFIC
    Label4.Text = "ADDRESS EVENT"
End Sub
Private Sub tapiObject_Event(ByVal sender As Object, _
  ByVal e As TapiObjectEventArgs) Handles MyTAPI.TE_TAPIOBJECT
    Label4.Text = "TAPI OBJECT EVENT"
End Sub
Private Sub tapiDigit_Event(ByVal sender As Object, _
  ByVal e As TapiDigitDetectionEventArgs) Handles MyTAPI.TE_DIGITEVENT
        Label4.Text = "DIGIT EVENT"
    End Sub

你需要这些活动。我一开始也遇到过同样的问题。如果没有这些事件,将不会触发CallInfo。

对不起,我也忘了这个:

Dim m_TAPI As New JulMar.Tapi3.TTapi
        m_TAPI.Initialize()
        MyTAPI = m_TAPI
        m_TAPI = Nothing
        For Each Phone As TPhone In MyTAPI.Phones
            For Each Address As TAddress In MyTAPI.Addresses()
                If Address.State = ADDRESS_STATE.AS_INSERVICE Then
                    If Address.AddressName.ToLower.StartsWith("cisco") Then
                        Try
                           Address.OpenAndMonitor(TAPIMEDIATYPES.AUDIO)
                        Catch ex As Exception
                            Address.Close()
                            Address.OpenAndMonitor(TAPIMEDIATYPES.AUDIO)
                        End Try
                        Label2.Text = Label2.Text & vbNewLine & Address.AddressName.ToLower & Address.State.ToString
                        If Address.AddressName.ToLower.Contains("6591") Then
                            TapiAddress = Address
                        End If
                    End If
                End If
            Next Address
        Next Phone

也需要触发。

 Address.OpenAndMonitor(TAPIMEDIATYPES.AUDIO)