/// <summary> /// Handle incoming audio call from the customer. /// </summary> /// <param name="audioCall">Audio call.</param> public void HandleIncomingAudioCall(AudioVideoCall audioCall) { lock (syncRoot) { if (this.conversation == null) { this.conversation = audioCall.Conversation; this.RegisterConversationEventHandlers(this.conversation); } this.audioIvr = new AudioIVR(audioCall, this.application.XmlParser, this.logger); try { audioCall.BeginAccept((asyncResult) => { try { audioCall.EndAccept(asyncResult); } catch (RealTimeException rte) { Console.WriteLine("Error accepting incoming AV call {0}", rte); this.logger.Log("Error accepting incoming AV call {0}", rte); } }, null); } catch (InvalidOperationException ioe) { Console.WriteLine("Error accepting incoming AV call {0}", ioe); this.logger.Log("Error accepting incoming AV call {0}", ioe); } } }
private void AcceptCall(AudioVideoCall call) { _avCall = call; try { // Accept the incoming call. _avCall.BeginAccept(ar => { try { _avCall.EndAccept(ar); _logger.Log("Accepted incoming call."); } catch (RealTimeException rtex) { _logger.Log("Failed accepting incoming A/V call.", rtex); } }, null); } catch (InvalidOperationException ioex) { _logger.Log("Failed accepting incoming A/V call.", ioex); } }
public void AcceptAVCall(AudioVideoCall call) { //Console.WriteLine("Accepting incoming AV call"); try { call.BeginAccept( ar => { try { call.Flow.StateChanged += new EventHandler<MediaFlowStateChangedEventArgs>(Flow_StateChanged); call.EndAccept(ar); SpeakMessage(call.Flow, string.Format("Hello, {0}. Thanks for calling. " + "Your SIP URI is {1}", call.RemoteEndpoint.Participant.DisplayName, call.RemoteEndpoint.Participant.Uri)); } catch (RealTimeException ex) { Console.WriteLine("Failed tp accept call.", ex); } }, null); } catch (InvalidOperationException ex) { Console.WriteLine("Failed tp accept call.", ex); } }
private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e) { _avCall = e.Call; try { // Accept the incoming call. _avCall.BeginAccept(ar => { try { _avCall.EndAccept(ar); _logger.Log("Accepted incoming call."); } catch (RealTimeException rtex) { _logger.Log("Failed accepting incoming A/V call.", rtex); } }, null); } catch (InvalidOperationException ioex) { _logger.Log("Failed accepting incoming A/V call.", ioex); } }
private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e) { _avCall = e.Call; _avCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(OnCallStateChanged); try { // Accept the incoming call. _avCall.BeginAccept(ar => { try { _avCall.EndAccept(ar); _logger.Log("Accepted incoming call."); PerformAttendedTransfer(); } catch (RealTimeException rtex) { _logger.Log("Failed accepting incoming A/V call.", rtex); } }, null); } catch (InvalidOperationException ioex) { _logger.Log("Failed accepting incoming A/V call.", ioex); } }
private void EndAcceptCall(IAsyncResult ar) { AudioVideoCall audioVideoCall = ar.AsyncState as AudioVideoCall; try { // End accepting the incoming call. audioVideoCall.EndAccept(ar); } catch (OperationFailureException OpFailEx) { // Operation failure exception can occur when the far end transfer // does not complete successfully, usually due to the transferee // failing to pick up. Console.WriteLine(OpFailEx.ToString()); } catch (RealTimeException realTimeEx) { // Real time exception can occur when the far end transfer does // not complete successfully, usually due to a link-layer or // transport failure (i.e: Link dead, or failure response.). Console.WriteLine(realTimeEx.ToString()); } finally { //Again, just to sync the completion of the code. _waitForCallAccept.Set(); } }
// Callback referenced in the BeginAccept method on the call. private void CallAcceptCB(IAsyncResult ar) { if (ar.IsCompleted) { _waitForCallAccepted.Set(); Console.WriteLine("Call is now accepted."); _audioVideoCall.EndAccept(ar); } else { Console.WriteLine("Couldn't accept the call."); } }
/// <summary> /// EventHandler raised when an incoming call arrives to the endpoint, above. /// </summary> /// <param name="sender">Object that sent the event</param> /// <param name="e">CallReceivedEventArgs object</param> private void AudioVideoCallReceived(object sender, CallReceivedEventArgs <AudioVideoCall> e) { //Assign the current call to the global keeper. currentCall = e.Call; currentCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(Call_AudioVideoFlowConfigurationRequested); //Bind handlers to the current call's state changed event to drive UI. //State change is used to inform the application of the current state of the call. //In particular, this should be used by the application to determine what operations are valid in a given state. currentCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(HandleCallStateChanged); // accept the incoming call and waits for State and configuration requests. currentCall.EndAccept(currentCall.BeginAccept(null, null)); }
private void AcceptAVCallCompleted(IAsyncResult ar) { AudioVideoCall audioVideoCall = ar.AsyncState as AudioVideoCall; try { // End accepting the incoming call. audioVideoCall.EndAccept(ar); } catch (RealTimeException exception) { // RealTimeException may be thrown on media or link-layer failures. // TODO (Left to the reader): Add error handling code here. Console.WriteLine(exception.ToString()); } finally { //Again, just to sync the completion of the code. } }
private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e) { _avCall = e.Call; try { // Accept the incoming call. _avCall.BeginAccept(ar => { try { _avCall.EndAccept(ar); _logger.Log("Accepted incoming call."); switch (_transferType) { case TransferTypeSelection.Attended: PerformAttendedTransfer(); break; case TransferTypeSelection.Unattended: PerformUnattendedTransfer(); break; case TransferTypeSelection.Supervised: PerformSupervisedTransfer(); break; } } catch (RealTimeException rtex) { _logger.Log("Failed accepting incoming A/V call.", rtex); } }, null); } catch (InvalidOperationException ioex) { _logger.Log("Failed accepting incoming A/V call.", ioex); } }
private void CallAcceptCB(IAsyncResult ar) { AudioVideoCall audioVideoCall = ar.AsyncState as AudioVideoCall; try { // Determine whether the call was accepted successfully. audioVideoCall.EndAccept(ar); } catch (RealTimeException exception) { // RealTimeException may be thrown on media or link-layer failures. // A production application should catch additional exceptions, such as OperationTimeoutException, // OperationTimeoutException, and CallOperationTimeoutException. Console.WriteLine(exception.ToString()); } finally { // Synchronize with main thread. _waitForCallToBeAccepted.Set(); } }