Dialogic logo

Using the Diva Component API

  Introduction  
     2 pages
  About the Component API  
     4 pages
  Preparing to use the API  
     2 pages
  Component API objects  
     2 pages
  Making and receiving calls  
     3 pages
  Voice, tones, fax & data  
     7 pages
  Accessing the adapters  
     2 pages
  Handling multiple calls  
     9 pages
  Using non-blocking mode  
     18 pages
  Samples  
 
  << Back     Next page >>  
Making a call

Programs and scripts can use the Component API in either 'blocking' or 'non-blocking' mode. The following examples use 'blocking' mode because this is the simplest. For more complex scripts and applications 'non-blocking' mode can make it easier to create programs that can cope with unforeseen sequences of events or errors.
See the section 'Handling multiple calls' for more information.

We can create the DivaCall object directly here because we are handling only one call; if we were creating more than one DivaCall object then we would have to use DivaSystem and DivaInstance and the DivaCall objects would be created using the CreateCall method of DivaInstance.

To make a call
The following code makes a call with Connect , plays the wave file with SendVoiceFile when the call is answered and Disconnects.

VB example: (Show C# version)

     Imports DivaSDKlib
     ...
     Dim res As DivaResultCodes
     Dim num As String = "1234567"
     ' Single call program, so create DivaCall directly
     Dim CallObj As New DivaCall()
         res = CallObj.Connect(num)
     If res = DivaResultCodes.DivaResultSuccess Then
         res = CallObj.SendVoiceFile("defaultgreeting.wav")
         ' Using synchronous (blocking) mode so next line is executed after 
         ' completion of previous operation
         res = CallObj.Disconnect
     End If

To receive a call
The following code waits for a call using WaitForCall and records a wave file with RecordVoiceFile when a call is received.

VB example: (Show C# version)

     Imports DivaSDKlib
     ...
     Dim res As DivaResultCodes
     ' Single call program, so create DivaCall directly
     Dim CallObj As New DivaCall()
     ' Using synchronous (blocking) mode with 'WaitForCall' rather than Asynchronous 'Listen'
     res = CallObj.WaitForCall
     If res = DivaResultCodes.DivaResultSuccess Then
        res = CallObj.RecordVoiceFile("myfile.wav")
        ' Using synchronous (blocking) mode so next line is executed after
        ' completion of previous operation
        res = CallObj.Disconnect
     End If

Of course, these samples are too simple for real-life use; for instance, they do not report to you whether they worked or not. However, they do show how simple it is to use the Diva Component API.

Copyright© 2016 Dialogic® Corporation. All rights reserved. Legal Notice
40-000.htm 100 10000