| TapiCallAnswer Method |
Namespace: Traysoft.AddTapi
| Exception | Condition |
|---|---|
| TapiException | The call was not answered because a TAPI error occurred. |
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.
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(); }