/// <summary> /// Terminate b2b call. /// </summary> private void TerminateBackToBackCall() { bool exceptionEncountered = true; try { BackToBackCall b2bCall = m_webConversation.BackToBackCall; if (b2bCall != null) { b2bCall.BeginTerminate(this.BackToBackCallTerminated, b2bCall); } else { //Go to next step of terminating conversation. this.TerminateConversation(); } exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// B2B call terminate completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void BackToBackCallTerminated(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { BackToBackCall b2bCall = asyncResult.AsyncState as BackToBackCall; b2bCall.EndTerminate(asyncResult); //Now try to terminate conversation. this.TerminateConversation(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Terminate conversation. /// </summary> private void TerminateConversation() { bool exceptionEncountered = true; try { Conversation conversation = m_webConversation.Conversation; if (conversation != null) { conversation.BeginTerminate(this.ConversationTerminated, conversation); } else { this.TerminationWorkCompleted(); } exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; Exception exceptionCaught = null; try { m_imFlow.BeginSendInstantMessage(m_textBody, this.InstantMessagingSendMessageCompleted, null /*state*/); exceptionEncountered = false; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteSendMessageOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Establishes back to back call due to incoming self transfer. /// </summary> /// <param name="b2bCall">Pre populated b2b call. Cannot be null.</param> internal void EstablishBackToBackCall(BackToBackCall b2bCall) { Debug.Assert(null != b2bCall, "B2B call is null"); Exception exceptionCaught = null; bool exceptionEncountered = true; try { b2bCall.BeginEstablish(this.BackToBackCallEstablishCompleted, b2bCall /*state*/); exceptionEncountered = false; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Terminate Im call. /// </summary> private void TerminateInstantMessagingCall() { bool exceptionEncountered = true; try { InstantMessagingCall imCall = null; WebImCall webImCall = m_webConversation.WebImCall; if (webImCall != null) { imCall = webImCall.ImCall; } if (imCall != null) { imCall.BeginTerminate(this.InstantMessagingCallTerminated, imCall); } else { //Go to next step of terminating av call. this.TerminateAudioVideoCall(); } exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// self transfer has completed. /// </summary> /// <param name="asyncResult">Async result.</param> private void SelfTransferCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_callbackCall.EndTransfer(asyncResult); //Self Transfer has completed. successfully. exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// B2B call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void BackToBackCallEstablishCompleted(IAsyncResult asyncResult) { var b2bCall = asyncResult.AsyncState as BackToBackCall; Debug.Assert(null != b2bCall, "Async state is null"); Exception exceptionCaught = null; bool exceptionEncountered = true; try { b2bCall.EndEstablish(asyncResult); //If the call establishment is successful, stamp the b2b call in the web conversation. this.WebConversation.BackToBackCall = b2bCall; exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } else { AudioVideoCallContext avCallContext = b2bCall.Call1.ApplicationContext as AudioVideoCallContext; Debug.Assert(null != avCallContext, "Av call context is null"); Debug.Assert(null != avCallContext.WebAvcall, "Av call in av call context is null"); EstablishAudioVideoCallResponse response = new EstablishAudioVideoCallResponse(m_establishAvCallRequest, avCallContext.WebAvcall); this.CompleteEstablishOperationSuccessfully(response); } } }
/// <summary> /// Establishes av call directly to the destination. /// </summary> private void EstablishAvCallDirectly() { bool exceptionEncountered = true; Exception exceptionCaught = null; try { CallEstablishOptions establishOptions = new CallEstablishOptions(); //Add custom MIME parts based on conversation context. if (m_cutomMimePart != null) { establishOptions.CustomMimeParts.Add(m_cutomMimePart); } //Construct the destination uri, if needed. m_avCall.BeginEstablish(m_destinationUri, establishOptions, this.AudioVideoCallEstablishCompleted, null /*state*/); exceptionEncountered = false; } catch (ArgumentException ae) { Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae)); exceptionCaught = ae; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; try { this.EstablishClickToCall(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; try { //If callback number is not specified then establish audio call directly to the destination. this.EstablishAvCallDirectly(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Overridden process method. /// </summary> public override void Process() { bool exceptionEncountered = true; try { //First terminate all calls and then terminate the conversation. this.TerminateInstantMessagingCall(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Im call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void InstantMessagingCallEstablishCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_imCall.EndEstablish(asyncResult); exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } else { InstantMessagingCallContext imCallContext = m_imCall.ApplicationContext as InstantMessagingCallContext; Debug.Assert(null != imCallContext, "Im call context is null"); Debug.Assert(null != imCallContext.WebImcall, "Im call in Imcall context is null"); //Stamp im call. m_webConversation.WebImCall = imCallContext.WebImcall; EstablishInstantMessagingCallResponse response = new EstablishInstantMessagingCallResponse(m_establishImCallRequest, imCallContext.WebImcall); this.CompleteEstablishOperationSuccessfully(response); } } }
/// <summary> /// Establish call by first calling the phone number and then doing self transfer and then back to backing with the destination. /// </summary> private void EstablishClickToCall() { bool exceptionEncountered = true; Exception exceptionCaught = null; try { string callbackPhoneUri = Helper.GetCallbackPhoneUri(m_establishAvCallRequest.CallbackPhoneNumber); m_callbackCall.BeginEstablish(callbackPhoneUri, null /*establishOptions*/, this.CallbackAudioVideoCallEstablishCompleted, null /*state*/); exceptionEncountered = false; } catch (ArgumentException ae) { Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae)); exceptionCaught = ae; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Callback Av call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void CallbackAudioVideoCallEstablishCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_callbackCall.EndEstablish(asyncResult); //If establish operation succeeds immediately trigger a self transfer. m_callbackCall.BeginTransfer(m_callbackCall, null /*transferOptions*/, this.SelfTransferCompleted, null /*asyncState*/); exceptionEncountered = false; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Conversation terminated callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void ConversationTerminated(IAsyncResult asyncResult) { bool exceptionEncountered = true; try { Conversation conv = asyncResult.AsyncState as Conversation; conv.EndTerminate(asyncResult); //Invoke all done. this.TerminationWorkCompleted(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Av call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void AudioVideoCallTerminated(IAsyncResult asyncResult) { bool exceptionEncountered = true; try { AudioVideoCall avCall = asyncResult.AsyncState as AudioVideoCall; avCall.EndTerminate(asyncResult); //Now try to terminate b2bcall. this.TerminateBackToBackCall(); exceptionEncountered = false; } finally { if (exceptionEncountered) { OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
/// <summary> /// Im call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void InstantMessagingSendMessageCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_imFlow.EndSendInstantMessage(asyncResult); exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteSendMessageOperationWithException(new FaultException <OperationFault>(operationFault)); } else { SendInstantMessageResponse response = new SendInstantMessageResponse(m_sendImMessageRequest); this.CompleteSendMessageOperationSuccessfully(response); } } }