AddTapi.NET Developer's Manual
Open Method (monitorIncomingCalls, callback)
NamespacesTraysoft.AddTapiTapiLineOpen(Boolean, TapiCallHandler)
Opens the line. After the line is opened, it can be used to monitor incoming calls and/or to place outgoing calls.
Declaration Syntax
C#Visual BasicVisual C++
public void Open(
	bool monitorIncomingCalls,
	TapiCallHandler callback
)
Public Sub Open ( _
	monitorIncomingCalls As Boolean, _
	callback As TapiCallHandler _
)
public:
void Open(
	bool monitorIncomingCalls, 
	TapiCallHandler^ callback
)
Parameters
monitorIncomingCalls (Boolean)
Indicates whether the line should monitor incoming calls.
callback (TapiCallHandler)
Callback method that will be called when a call is connected.
Remarks

The line has to be opened before it can be used to place outgoing calls and receive incoming calls. If your application only makes outgoing calls and does not need to be notified about incoming calls, pass false as the monitorIncomingCalls parameter. If you pass true, AddTapi.NET will monitor incoming calls on the line and fire IncomingCall events. When monitorIncomingCalls parameter is true, AddTapi.NET will also answer incoming calls if RingsToAnswer is greater than zero.

The callback parameter represents a method in your application that AddTapi.NET will call when a call is connected. This method will be called for all connected calls, incoming and outgoing. This method should perform application-specific call flow processing. Please see TapiCallHandler for more information.

When you use this method, AddTapi.NET automatically selects appropriate media modes based on the capabilities of telephony hardware. Use Open(Boolean, TapiCallHandler, TapiMediaMode) if you want to open the line device for calls with specific media types (modes).

Examples
The following code shows how to open the line to process incoming calls. 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
            
Exceptions
ExceptionCondition
TapiExceptionOpen failed because of Telephony API (TAPI) error.
See Also

Assembly: Traysoft.AddTapi (Module: Traysoft.AddTapi)