永远不会发生TAPI_EVENT.TE_CALLINFOCHANGE事件

时间:2011-11-03 08:42:56

标签: c# tapi

我的过滤器包含以下所有内容。我想在接听电话时看到每个事件。这些都发生了:

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

我想获得来电显示。线路连接到手机时,我可以看到被叫ID。但它没有发起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);

2 个答案:

答案 0 :(得分:2)

最近我在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;
        }
    }
}

答案 1 :(得分:0)

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)