
Public Class VBSIPProxyCallsEnv
    Inherits GTAPIASM.GTAPIEnv
    Public m_pMainWnd As Form1
    Public m_sForwardingAddr As String

    Public Overrides Sub On_RecvConnected(ByVal ch As Integer)
        MyBase.On_RecvConnected(ch)
    End Sub

    Public Overrides Sub On_RecvDialing(ByVal ch As Integer, ByVal sCaller As String, ByVal sCallee As String)
        MyBase.On_RecvDialing(ch, sCaller, sCallee)
    End Sub


    Public Overrides Sub On_RecvOffered(ByVal ch As Integer, ByVal sCaller As String, ByVal sCallee As String, ByVal sDestAddr As String, ByVal sViaAddr As String, ByVal sFromIP As String, ByVal nFromPort As System.UInt16)
        MyBase.On_RecvOffered(ch, sCaller, sCallee, sDestAddr, sViaAddr, sFromIP, nFromPort)
    End Sub

    Public Overrides Sub On_RecvIdle(ByVal ch As Integer, ByVal code As Integer, ByVal desc As String)
        MyBase.On_RecvIdle(ch, code, desc)
    End Sub

    Public Overrides Sub On_RecvRinging(ByVal ch As Integer)
        MyBase.On_RecvRinging(ch)
    End Sub

    Public Overrides Sub On_RecvRegStatus(ByVal user_id As Integer, ByVal status As Integer, ByVal regtime As Integer)
        MyBase.On_RecvRegStatus(user_id, status, regtime)
    End Sub

    Public Overrides Sub On_RecvDTMFKeyDown(ByVal ch As Integer, ByVal keyValue As Byte, ByVal ticks As System.UInt32)
        MyBase.On_RecvDTMFKeyDown(ch, keyValue, ticks)
    End Sub

    Public Overrides Sub On_RecvDTMFKeyUp(ByVal ch As Integer, ByVal keyValue As Byte, ByVal ticks As System.UInt32)
        MyBase.On_RecvDTMFKeyUp(ch, keyValue, ticks)
    End Sub

    Public Overrides Sub On_RecvDTMFDone(ByVal ch As Integer, ByVal doneReason As Integer, ByVal dtmfBuf As String)
        MyBase.On_RecvDTMFDone(ch, doneReason, dtmfBuf)
    End Sub

    Public Overrides Sub On_VoiceActivityDetected(ByVal ch As Integer, ByVal voice_dir As Integer, ByVal voice_on As Integer, ByVal level As Integer, ByVal reserved As System.UInt32)
        MyBase.On_VoiceActivityDetected(ch, voice_dir, voice_on, level, reserved)
    End Sub

    Public Overrides Function On_ProxyNewCallSession(ByVal pid As UInteger, ByVal sid As UInteger, ByVal msg As System.IntPtr, ByVal authid As String, ByVal fromid As String, ByVal toid As String, ByVal suri As String, ByVal via As String, ByVal saddr As String, ByVal nport As UShort, ByVal bCredit As Boolean) As String
        'Return MyBase.On_ProxyNewCallSession(pid, sid, msg, authid, fromid, toid, suri, via, saddr, nport, bCredit)
        '             
        '             Possible Return values:
        '             "sip:undefined" = wait until ProxySetNewCallSessionAddr is called
        '             Sometimes you cannot immediately decide what to do with Me call, and then you can call ProxySetNewCallSessionAddr function to provide an address later.
        '             NOTE: The OCX(ActiveX) users should(have to) use ProxySetNewCallSessionAddr function later to provide one of the following values:
        '             "channel" = to channel. Default value. Then one of the channels will have On_RecvOffered event triggered.
        '             "unauthorized" = need credit to process. You should check the fromID, to see if it is a call from proxy site’s user(or extension of PBX). If it does, and Credit is False, then “unauthorized” String is Returned to ask authorization to call .
        '             "sip:123@abc.com" = with right credit or don't need credit, processed by proxy site and transfered to Me address
        '             "|" can be used to seperate the credit info. For example: "To<sip:123@abc.com>|From<sip:456@abc.com>|User<1234>|Password<4567>"
        '             Otherwise, if none of above matched, refer to user's contact info.
        '             */

        'forward any calls to PC Best Music Server:
        Return m_sForwardingAddr
    End Function

End Class

