1

我的过滤器包含下面的所有内容。我想在来电时查看每个事件。这些都发生了:

--- 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);
4

2 回答 2

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;
        }
    }
}
于 2012-09-13T10:54:44.630 回答
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)
于 2017-06-26T08:23:51.193 回答