⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 call.vb

📁 三汇CTI示例程序源码
💻 VB
📖 第 1 页 / 共 2 页
字号:
                Case ShEvent.E_CHG_ChState
                    nCh = uMsg.WParam.ToInt32
                    nNewState = CInt(uMsg.LParam.ToInt32 And &HFFFF&)       'New state
                    Select Case nNewState
                        Case ChState.S_CALL_RINGING                               'ringing
                            If ChInfo(nCh).nStep = TrkChState.TRK_IDLE Then
                                If SsmPickup(nCh) = -1 Then
                                    MsgBox("Fail to call SsmPickup")
                                End If
                                If SsmClearRxDtmfBuf(nCh) = -1 Then         'Clear received DTMF buffer
                                    MsgBox("Fail to call SsmClearRxDtmfBuf")
                                End If
                                ChInfo(nCh).szDtmf = ""
                                ChInfo(nCh).nStep = TrkChState.TRK_WAIT_CONNECT
                            End If

                        Case ChState.S_CALL_TALKING                                 'talking
                            If ChInfo(nCh).nStep = TrkChState.TRK_WAIT_CONNECT Then
                                SsmClearFileList(nCh)
                                ChInfo(nCh).szCallerId = New System.Text.StringBuilder(20)
                                If SsmGetCallerId(nCh, ChInfo(nCh).szCallerId) = -1 Then
                                    MsgBox("Fail to call SsmGetCallerId")
                                End If

                                If SsmAddToFileList(nCh, System.IO.Directory.GetCurrentDirectory + "..\..\..\..\..\..\DemoVoc\Welcom1.voc", 6, 0, -1) = -1 Or _
                                    SsmAddToFileList(nCh, System.IO.Directory.GetCurrentDirectory + "..\..\..\..\..\..\DemoVoc\Welcom2.voc", 6, 0, -1) = -1 Then
                                    MsgBox("Fail to call SsmAddToFile")
                                End If

                                If SsmPlayFileList(nCh) = -1 Then           'Play "welcome"
                                    MsgBox("Fail to call SsmPlayFileList")
                                End If

                                ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_WELCOME
                            End If

                        Case ChState.S_CALL_PENDING                                 'hangup
                            Select Case ChInfo(nCh).nStep
                                Case TrkChState.TRK_CHECK_PLAY_WELCOME
                                    If SsmStopPlayFileList(nCh) = -1 Then   'Stop playing "welcome"
                                        MsgBox("Fail to call SsmStopPlayFileList")
                                    End If
                                    If SsmHangup(nCh) = -1 Then
                                        MsgBox("Fail to call SsmHangup")
                                    End If
                                    ChInfo(nCh).nStep = TrkChState.TRK_IDLE

                                Case TrkChState.TRK_CHECK_PLAY_SELECT
                                Case TrkChState.TRK_CHECK_REC_START
                                    If SsmStopTimer(ChInfo(nCh).nTimer) = -1 Then
                                        MsgBox("Fail to call SsmStopTimer")
                                    End If
                                    If SsmStopPlay(nCh) = -1 Then
                                        MsgBox("Fail to call SsmStopPlay")
                                    End If
                                    ChInfo(nCh).nTimer = -1
                                    If SsmHangup(nCh) = -1 Then
                                        MsgBox("Fail to call SsmHangup")
                                    End If
                                    ChInfo(nCh).nStep = TrkChState.TRK_IDLE

                                Case TrkChState.TRK_CHECK_REC_END
                                    If SsmStopRecToFile(nCh) = -1 Then      'Stop recording
                                        MsgBox("Fail to call SsmStopRecToFile ddd")
                                    End If
                                    If SsmHangup(nCh) = -1 Then
                                        MsgBox("Fail to call SsmHangup")
                                    End If
                                    ChInfo(nCh).nStep = TrkChState.TRK_IDLE

                                Case TrkChState.TRK_CHECK_PLAY_RECORD
                                    If SsmStopPlay(nCh) = -1 Then
                                        MsgBox("Fail to call SsmStopPlay")
                                    End If
                                    If SsmHangup(nCh) = -1 Then
                                        MsgBox("Fail to call SsmHangup")
                                    End If
                                    ChInfo(nCh).nStep = TrkChState.TRK_IDLE

                            End Select
                    End Select

                Case ShEvent.E_PROC_PlayEnd
                    nCh = uMsg.WParam.ToInt32
                    If ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_WELCOME Then
                        If SsmSetDtmfStopPlay(nCh, 1) = -1 Then     'Turn on 'DTMF_stop_play' switch
                            MsgBox("Fail to call SsmSetDtmfStopPlay")
                        End If
                        If SsmPlayIndexString(nCh, "Select") = -1 Then  'Play "select"
                            MsgBox("Fail to call SsmPlayIndexString")
                        End If
                        ChInfo(nCh).nTimer = SsmStartTimer(15000, 1)
                        If (ChInfo(nCh).nTimer = -1) Then
                            MsgBox("Fail to call SsmStartTimer")
                        End If
                        If SsmClearRxDtmfBuf(nCh) = -1 Then     'Clear received DTMF buffer
                            MsgBox("Fail to call SsmClearRxDtmfBuf")
                        End If
                        ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_SELECT

                    ElseIf ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_BYEBYE Then
                        If SsmHangup(nCh) = -1 Then
                            MsgBox("Fail to call SsmHangup")
                        End If
                        ChInfo(nCh).nStep = TrkChState.TRK_IDLE

                    ElseIf ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_RECORD Then
                        If uMsg.LParam.ToInt32 = 1 Then 'lParam = 1 Then

                            If (SsmPlayIndexString(nCh, "Byebye") = -1) Then
                                MsgBox("Fail to call SsmPlayIndexString")
                            End If
                            ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_BYEBYE
                        End If
                    End If

                Case ShEvent.E_SYS_TIMEOUT
                    'identify the channel number according to the flag 'timer'
                    For i = 0 To nMaxCh - 1
                        If uMsg.WParam.ToInt32 = ChInfo(i).nTimer Then
                            nCh = i
                            Exit For
                        End If
                    Next i
                    If ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_SELECT _
                        Or ChInfo(nCh).nStep = TrkChState.TRK_CHECK_REC_START Then
                        If SsmStopTimer(ChInfo(nCh).nTimer) = -1 Then
                            MsgBox("Fail to call SsmStopTimer")
                        End If
                        ChInfo(nCh).nTimer = -1
                        If (SsmPlayIndexString(nCh, "Byebye") = -1) Then
                            MsgBox("Fail to call SsmPlayIndexString ")
                        End If
                        ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_BYEBYE
                    End If

                Case ShEvent.E_PROC_RecordEnd
                    nCh = uMsg.WParam.ToInt32
                    If (ChInfo(nCh).nStep = TrkChState.TRK_CHECK_REC_END) Then
                        If (SsmPlayIndexString(nCh, "Byebye") = -1) Then
                            MsgBox("Fail to call SsmPlayIndexString ")
                        End If
                        ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_BYEBYE
                    End If

                    'Event generated by the driver when DTMF is received
                Case ShEvent.E_CHG_RcvDTMF
                    nCh = uMsg.WParam.ToInt32
                    cNewDtmf = Chr(&HFFFF& And uMsg.LParam.ToInt32)
                    'Newly received DTMF
                    ChInfo(nCh).szDtmf = ChInfo(nCh).szDtmf + cNewDtmf

                    Select Case ChInfo(nCh).nStep
                        Case TrkChState.TRK_CHECK_PLAY_SELECT
                            'Choose 1 - Make a record
                            'Choose 2 - Listen to record
                            If cNewDtmf = "1" Then
                                If SsmPlayIndexString(nCh, "RecPrompt") = -1 Then
                                    MsgBox("Fail to call SsmPlayIndexString")
                                End If
                                If SsmStopTimer(ChInfo(nCh).nTimer) = -1 Then
                                    MsgBox("Fail to call SsmStopTimer")
                                End If
                                ChInfo(nCh).nTimer = SsmStartTimer(15000, 1)
                                If ChInfo(nCh).nTimer = -1 Then
                                    MsgBox("Fail to call SsmStartTimer")
                                End If
                                ChInfo(nCh).nStep = TrkChState.TRK_CHECK_REC_START

                            ElseIf cNewDtmf = "2" Then
                                If SsmStopTimer(ChInfo(nCh).nTimer) = -1 Then
                                    MsgBox("SsmStopTimer")
                                End If
                                ChInfo(nCh).nTimer = -1
                                If SsmSetDtmfStopPlay(nCh, 0) = -1 Then
                                    MsgBox("Fail to call SsmSetDtmfStopPlay")
                                End If
                                If (SsmPlayFile(nCh, "test.voc", 6, 0, &HFFFFFFFF) = -1) Then
                                    MsgBox("Fail to call SsmPlayFile")
                                End If
                                ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_RECORD
                            End If

                            ' Press "*" - Start recording
                            ' Press "#" - Stop recording

                        Case TrkChState.TRK_CHECK_REC_START
                            If cNewDtmf = "*" Then
                                'Recording…
                                If SsmRecToFile(nCh, "test.voc", 6, 0, 80000, 0, 0) = -1 Then 'start from 16000L,maxmium 10 seconds
                                    MsgBox("Fail to call SsmRecToFile")
                                End If
                                If SsmStopTimer(ChInfo(nCh).nTimer) = -1 Then
                                    MsgBox("Fail to call SsmStopTimer")
                                End If
                                ChInfo(nCh).nTimer = -1
                                ChInfo(nCh).nStep = TrkChState.TRK_CHECK_REC_END
                            End If

                        Case TrkChState.TRK_CHECK_REC_END
                            If cNewDtmf = "#" Then
                                If SsmStopRecToFile(nCh) = -1 Then      'Stop recording
                                    MsgBox("Fail to call SsmStopRecToFile")
                                End If
                                If (SsmPlayIndexString(nCh, "Byebye") = -1) Then
                                    MsgBox("Fail to call SsmPlayIndexString")
                                End If
                                ChInfo(nCh).nStep = TrkChState.TRK_CHECK_PLAY_BYEBYE
                            End If

                    End Select

            End Select

            UpdateCircuitListCtrl()

        Else
            MyBase.WndProc(uMsg)

        End If

    End Sub

End Class
Public Structure EVENT_SET_INFO
    Public dwWorkMode As Int32
    Public lpHandlerParam As Int32
    Public dwOutCondition As Int32
    Public dwOutParamVal As Int32
    Public dwUser As Int32
End Structure
Public Structure CH_INFO
    Public nEnCalled As Int32               'whether enable call in or not
    Public nStep As Int32                   'Channel state
    Public szCallerId As System.Text.StringBuilder 'Calling party number
    Public szDtmf As String                'Received DTMF
    Public nTimer As Int32                  'Timer
End Structure

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -