Answer Multiple Calls on VB6 Sample

rated by 0 users
This post has 12 Replies | 2 Followers

Top 500 Contributor
Posts 26
Points 305
Lisandro.Rocha Posted: 02-09-2010 5:45 AM

Hi,

I have a answer multiple calls sample on .Net that comes with the SDK. Can you please attach a Vb6 sample of multiple call answering?. Im using VBA to do my application, thats equivalent to VB6.

Thank you.

  • | Post Points: 20
Top 10 Contributor
Male
Posts 2,075
Points 27,747
Dialogic Employee

Because VBA/VB6 has no support for multi-threading you will have to code multiple call handling in a slightly clumsy way with specific call objects and associated event handlers for each channel. This works ok but does result in quite large programs if you have complex call flows. Simple example of two calls here:

Dim WithEvents CallObj1 As DivaCall
Dim WithEvents CallObj2 As DivaCall

Dim SysObj As DivaSystem
Dim InstObj As DivaInstance

Private Sub Form_Load()

Set SysObj = CreateObject("DivaSDK.DivaSystem")
Set InstObj = SysObj.CreateInstance(True, 10, 7, 2048)
Set CallObj1 = InstObj.CreateCall
Set CallObj2 = InstObj.CreateCall

CallObj1.AsyncMode = True
CallObj1.SignalEvents = True
CallObj1.EnableDigitDetection = True

CallObj1.Listen(DivaListenServiceAnalogAll)

CallObj2.AsyncMode = True
CallObj2.SignalEvents = True
CallObj2.EnableDigitDetection = True

CallObj2.Listen(DivaListenServiceAnalogAll)

Private Sub CallObj1_OnIncomingCall()
    CallObj1.Alert
    WriteMessage "Call on Object 1 from " & CallObj1.CallingNumber
    CallObj1.Answer
    WriteMessage1 "Call on Object 1 answered "
End Sub

Private Sub CallObj2_OnIncomingCall()
    CallObj2.Alert
    MessageBox "Call on Object 2 from " & CallObj2.CallingNumber
    CallObj2.Answer
    MessageBox "Call on Object 2 answered "
End Sub

Private Sub CallObj1_OnConnected()
     MessageBox "Call on Object 1 Connected "
End Sub

Private Sub CallObj2_OnConnected()
     MessageBox "Call on Object 2 Connected "
End Sub

You can see you have two event handlers, one for an incoming call, one for when the call connects and each event handler needs to be coded for the specific call object so if you have 30 channels and 10 different event handlers you will need 300 'subroutines' - so programs get a little unwieldy to maintain.

 

  • | Post Points: 20
Top 500 Contributor
Posts 26
Points 305

Perfect Vic. Thank You.

Just one more question: In this way can I capture the fisical channel Im receiving the call?

  • | Post Points: 20
Top 10 Contributor
Male
Posts 2,075
Points 27,747
Dialogic Employee

Generally CallObj1 will be on channel 1 (port 1 for an Analog board) and CallObj2 on channel 2 etc just because of the order of declerations but you can always use the .Channel function to capture or to set the channel. eg

Capturing channel used for Incoming call :

Private Sub CallObj1_OnConnected()
     Channel = CallObj1.Channel
     MessageBox "Connected " & " using channel " & Channel

Setting channel to use for outbound call:

CallObj1.Channel = 1
CallObj1.Connect(dialnum, DivaCallType_Voice)

  • | Post Points: 20
Top 500 Contributor
Posts 26
Points 305

Many Thanks Vic.

  • | Post Points: 5
Top 500 Contributor
Posts 26
Points 305

I do it like you oriented me but when I tried on syncronous mode when I try answer the 2nd channel I get InvalidParameter(4) error code., if I try on async mode, does not work properly.

Its a call answer, play a menu (now Im just playing a menu, next I will use the EX function to get the results), reverse the call, and send a fax back. Works fine on 1 channel and syncronous mode.

 This is the code:

Lisandro.Rocha:

Private Sub Carrega_Atendimento()
    'Canal 1
    Set CallIn1 = CreateObject("DivaSDK.DivaCall")
    CallIn1.LocalNumber = "9872288"
    'CallIn1.AsyncMode = True
    CallIn1.SignalEvents = True
    CallIn1.EnableDigitDetection = True
    Call CallIn1.Listen(DIVASDKLib.DivaListenServices.DivaListenServiceAnalogAll, "")
    LogToWindow 1, "Diva Service: Aguardando Ligaes..."
   
    'Canal 2
    Set CallIn2 = CreateObject("DivaSDK.DivaCall")
    CallIn2.LocalNumber = "9872288"
    'CallIn2.AsyncMode = True
    CallIn2.SignalEvents = True
    CallIn2.EnableDigitDetection = True
    Call CallIn2.Listen(DIVASDKLib.DivaListenServices.DivaListenServiceAnalogAll, "")
    LogToWindow 2, "Diva Service: Aguardando Ligaes..."
    
   End Sub

Private Sub LogToWindow(Canal As Integer, TextLog As String)
    Me.ATENDMSG = Now & " (" & Canal & ") " & TextLog & vbCrLf & Me.ATENDMSG
End Sub

Sub CallIn1_OnIncomingCall()
    Dim retval As DivaResultCodes
   
    LogToWindow 1, "Recebendo ligao de <" & CallIn1.CallingNumber & ">"
    retval = CallIn1.Answer(DivaCallType_Voice)
    If (retval = DivaResultSuccess) Then
      LogToWindow 1, "Conectado, tocando apresentacao"
      retval = CallIn1.SendVoiceFiles("AOD,ME03,S,AOD,S,S,ME03")
      If (retval = DivaResultSuccess) Then
        CallIn1.FaxReverseSession = True
        retval = CallIn1.SetCallType(DivaCallType_Fax)
        CallIn1.FaxLocalId = "URATALK"
        CallIn1.FaxHeadLine = "Enviando fax de teste"
      Else
        LogToWindow 1, "Ligao desconectada"
      End If
    End If
End Sub

Private Sub CallIn1_OnConnected()
    Dim retval
    retval = CallIn1.SendFax("C:\Sistemas\Fax\Fax_CB1002.tif")
End Sub

Sub CallIn2_OnIncomingCall()
    Dim retval As DivaResultCodes
   
    LogToWindow 2, "Recebendo ligao de <" & CallIn2.CallingNumber & ">"
    retval = CallIn2.Answer(DivaCallType_Voice)
    If (retval = DivaResultSuccess) Then
      LogToWindow 2, "Conectado, tocando apresentacao"
    
      retval = CallIn2.SendVoiceFiles("AOD,ME03,S,AOD,S,S,ME03")
      If (retval = DivaResultSuccess) Then
        CallIn2.FaxReverseSession = True
        retval = CallIn2.SetCallType(DivaCallType_Fax)
        CallIn2.FaxLocalId = "URATALK"
        CallIn2.FaxHeadLine = "Enviando fax de teste"
      Else
        LogToWindow 2, "Ligao desconectada"
      End If
    End If
End Sub

Private Sub CallIn2_OnConnected()
    Dim retval
    retval = CallIn2.SendFax("C:\Sistemas\Fax\Fax_CB1002.tif")
End Sub

Thanks in Advance Vic.

  • | Post Points: 5
Top 500 Contributor
Posts 26
Points 305

If you have any news please update me.

Thanks in Advance Vic.

  • | Post Points: 5
Top 500 Contributor
Posts 26
Points 305

Any news Vic?

  • | Post Points: 5
Top 500 Contributor
Posts 26
Points 305

Hi Vic,

Can you please give any info, even if its on apreciation of DEV Team. Im with my development stopped.

Many thanks in advance.

  • | Post Points: 20
Top 10 Contributor
Male
Posts 2,075
Points 27,747
Dialogic Employee

Hi Lisandro, sorry for the delay, I've been travelling a lot on business and just haven't had the time to do much on the forum. I'll try to take a look at this tomorrow or over the weekend.

If you are under time pressure its always best to contact the support team, you will need a support contract for this though.

  • | Post Points: 20
Top 500 Contributor
Posts 26
Points 305

Please when you have any news please update me.

  • | Post Points: 20
Top 10 Contributor
Male
Posts 2,075
Points 27,747
Dialogic Employee

To handle multiple calls you need to create all the DivaCall objects using the CreateCall method of DivaInstance:

 Dim SysObj As DIVASDKLib.DivaSystem
 Dim InstObj As DIVASDKLib.DivaInstance
 SysObj = CreateObject("DivaSDK.DivaSystem")
 InstObj = SysObj.CreateInstance(True, 4, 7, 256)

 MyCall1 = InstObj.CreateCall
 MyCall1.AsyncMode = True
 MyCall2 = InstObj.CreateCall
 MyCall2.AsyncMode = True
       

The online training course here explains this in more detail.

http://www.dialogic.com/support/training/

  • | Post Points: 20
Top 500 Contributor
Posts 26
Points 305

I will try it. But I doit the proper CreateCall and seems working fine now.

thank you for your support Vic!

  • | Post Points: 5
Page 1 of 1 (13 items) | RSS