Represents a method that will perform call flow processing.
- call (TapiCall)
- A call to be processed.
When a call is connected, AddTapi.NET calls a method that will perform application-specific call flow processing.
For an example of such methods please refer to the samples included in AddTapi.NET installation.
Please note that your method must call Disconnect()()() to release the call before the method exits
if the call is no longer needed and should be disconnected.
The method represented by this delegate is called on a separate thread and executed in the background.
Several copies of this method can be executed at the same time (one for each line).
If you call other methods of your class or access other classes, make sure you do that in a thread-safe manner.
Windows Forms controls cannot be accessed directly in this method because it is called on a non-UI thread.
The application must use Invoke mechanism to access Windows Forms controls from this method.
Please refer to the included samples for an example of using Invoke to update Windows Forms controls.
The following code shows how to define a method for call flow processing. Error handling has been omitted for clarity.
C#
TapiApp.Initialize("MyApp");
TapiLine line = TapiApp.Lines[0];
line.Open(true, CallHandler);
line.RingsToAnswer = 1;
...
// This method will be called when incoming call is answered
private void CallHandler(TapiCall call)
{
call.Play("welcome.wav");
call.Speak("Press 1 to hear the current time. Press any other button to disconnect.");
if(call.WaitForDigit(20) == "1")
{
call.Speak(DateTime.Now.ToString());
call.WaitUntilDone(10);
}
call.Disconnect();
}
VB.NET
TapiApp.Initialize("MyApp")
Dim objLine As TapiLine
objLine = TapiApp.Lines(0)
objLine.Open(True, AddressOf CallHandler)
objLine.RingsToAnswer = 1;
...
' This method will be called when incoming call is answered
Private Sub CallHandler(ByVal objCall As TapiCall)
objCall.Play("welcome.wav")
objCall.Speak("Press 1 to hear the current time. Press any other button to disconnect.")
If objCall.WaitForDigit(20) = "1" Then
objCall.Speak(DateTime.Now.ToString())
objCall.WaitUntilDone(10)
End If
objCall.Disconnect()
End Sub
Assembly: Traysoft.AddTapi (Module: Traysoft.AddTapi)