Click or drag to resize
TapiLineOpen Method (Boolean, TapiCallHandler, TapiMediaMode, TapiCallPrivilege)
Opens the line for calls with selected media types (modes) and call privileges. After the line is opened, it can be used to monitor incoming calls and/or to place outgoing calls.

Namespace: Traysoft.AddTapi
Assembly: Traysoft.AddTapi (in Traysoft.AddTapi.dll) Version: 6.0.0.1110
Syntax
public void Open(
	bool monitorIncomingCalls,
	TapiCallHandler callback,
	TapiMediaMode mediaModes,
	TapiCallPrivilege privilege
)

Parameters

monitorIncomingCalls
Type: SystemBoolean
Indicates whether the line should monitor incoming calls.
callback
Type: Traysoft.AddTapiTapiCallHandler
Callback method that will be called when a call is connected.
mediaModes
Type: Traysoft.AddTapiTapiMediaMode
The media type or modes of interest to the application.
privilege
Type: Traysoft.AddTapiTapiCallPrivilege
The rights or privileges the application wants when notified of a call.
Exceptions
ExceptionCondition
TapiExceptionOpen failed because of Telephony API (TAPI) error.
Remarks

The line has to be opened before it can be used to place outgoing calls and receive incoming calls. If the application only makes outgoing calls and does not need to be notified about incoming calls, pass false as the monitorIncomingCalls parameter. AddTapi.NET will monitor incoming calls on the line and fire IncomingCall events if monitorIncomingCalls parameter is true. 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 the 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.

The mediaModes parameter is used to register the application as having an interest in monitoring calls that are of the specified media types. The application can register for multiple media types. The application should include TapiMediaMode.AutomatedVoice media mode if the application wants to use voice functionality such as playing wave files using Play(String) and speaking to the caller using Speak(String). Specifying TapiMediaMode.Unknown media mode indicates that the application wants to control unclassified calls (calls of unknown media type). To obtain a list of media modes supported by the line hardware please use AvailableMediaModes properties.

Examples
The following code shows how to open the line to process incoming calls. Error handling has been omitted for clarity.
TapiApp.Initialize("MyApp");
TapiLine line = TapiApp.Lines[0];
line.Open(true, CallHandler, TapiMediaMode.InteractiveVoice | TapiMediaMode.AutomatedVoice );
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();
}
See Also