Click or drag to resize
TapiCallAnswer Method
Answers incoming call.

Namespace: Traysoft.AddTapi
Assembly: Traysoft.AddTapi (in Traysoft.AddTapi.dll) Version: 6.0.0.1110
Syntax
public void Answer()
Exceptions
ExceptionCondition
TapiExceptionThe call was not answered because a TAPI error occurred.
Remarks

AddTapi.NET answers all incoming calls automatically if RingsToAnswer is greater than zero. The application can set RingsToAnswer to zero and use Answer method if it needs to answer specific calls instead of all calls.

Answer is an asynchronous operation. Answer method requests the call to be answered and returns immediately. Telephony hardware will answer the call within a few seconds after the Answer call. AddTapi.NET fires CallConnected event and executes TapiCallHandler passed to Open(Boolean, TapiCallHandler) when the call is answered and connection is established.

Examples
The following code shows how to use Answer method to answer calls from a specific number. The error handling was omitted for clarity.
TapiApp.Initialize("MyApp");
TapiApp.IncomingCall += OnIncomingCall;
TapiLine line = TapiApp.Lines[0];
line.Open(true, CallHandler);
line.RingsToAnswer = 0;
...

void OnIncomingCall(object sender, TapiEventArgs args)
{
    TapiCall call = args.Call;
    // Answer calls from 555-123-4567
    if (call.CallerID == "5551234567")
    {
        call.Answer();
    }
}

// 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