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.
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 DivaCallDim WithEvents CallObj2 As DivaCall
Dim SysObj As DivaSystemDim InstObj As DivaInstance
Private Sub Form_Load()
Set SysObj = CreateObject("DivaSDK.DivaSystem")Set InstObj = SysObj.CreateInstance(True, 10, 7, 2048)Set CallObj1 = InstObj.CreateCallSet CallObj2 = InstObj.CreateCall
CallObj1.AsyncMode = TrueCallObj1.SignalEvents = TrueCallObj1.EnableDigitDetection = True
CallObj1.Listen(DivaListenServiceAnalogAll)
CallObj2.AsyncMode = TrueCallObj2.SignalEvents = TrueCallObj2.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.
Perfect Vic. Thank You.
Just one more question: In this way can I capture the fisical channel Im receiving the call?
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 = 1CallObj1.Connect(dialnum, DivaCallType_Voice)
Many Thanks Vic.
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.ATENDMSGEnd 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 IfEnd 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 IfEnd Sub Private Sub CallIn2_OnConnected() Dim retval retval = CallIn2.SendFax("C:\Sistemas\Fax\Fax_CB1002.tif")End Sub
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.ATENDMSGEnd 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 IfEnd 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 IfEnd Sub
Private Sub CallIn2_OnConnected() Dim retval retval = CallIn2.SendFax("C:\Sistemas\Fax\Fax_CB1002.tif")End Sub
Thanks in Advance Vic.
If you have any news please update me.
Any news Vic?
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.
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.
Please when you have any news please update me.
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/
I will try it. But I doit the proper CreateCall and seems working fine now.
thank you for your support Vic!