/// <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));
                }
            }
        }
Ejemplo n.º 2
0
        void  _speechRecognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            Log("_speechRecognitionEngine_SpeechRecognized " +
                "Confidence=" + e.Result.Confidence + " " +
                "Text=" + e.Result.Text);

            if (e.Result.Text == "next")
            {
                _userCallTransferPath = UserCallTransferPath.Next;
            }
            else if (e.Result.Text == "previous")
            {
                _userCallTransferPath = UserCallTransferPath.Previous;
            }

            // Performing a self-transfer
            AudioVideoCall avCall = (AudioVideoCall)_b2bCall.Call1;

            avCall.BeginTransfer(avCall,
                                 ar =>
            {
                try
                {
                    avCall.EndTransfer(ar);
                }
                catch (Exception ex)
                {
                    Log(ex.ToString());
                }
            },
                                 null);
        }
Ejemplo n.º 3
0
        private void EndTransferCall(IAsyncResult ar)
        {
            AudioVideoCall audioVideoCall = ar.AsyncState as AudioVideoCall;

            try
            {
                // End transferring the incoming call.
                audioVideoCall.EndTransfer(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.
                _waitForTransferComplete.Set();
            }
        }
Ejemplo n.º 4
0
        private void TransferCallCompleted(IAsyncResult ar)
        {
            AudioVideoCall audioVideoCall = ar.AsyncState as AudioVideoCall;

            try
            {
                // End transferring the incoming call.
                audioVideoCall.EndTransfer(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());
            }

            // Again, just to sync the completion of the code.
            _sampleCompleted.Set();
        }
Ejemplo n.º 5
0
        private void ProcessCall(object state)
        {
            WaitHandle.WaitAll(waitToProcessCall);

            InitializeVoiceXmlBrowser();

            PlayMenu("mainmenu");

            waitForMenuInput.WaitOne();

            // Calling part here
            voiceXmlBrowser.Dispose();
            voiceXmlBrowser = null;

            audioVideoCall.StateChanged -= this.AudioVideoCall_StateChanged;

            if (selectedOptions.Count >= 2)
            {
                if (!string.IsNullOrEmpty(selectedOptions[0]) && !string.IsNullOrEmpty(selectedOptions[1]))
                {
                    string helpdeskExtension = parser.HelpdeskNumber(selectedOptions[0], selectedOptions[1]);
                    if (!string.IsNullOrEmpty(helpdeskExtension))
                    {
                        this.logger.Log("Transferring user {0} to helpdesk# {1}", audioVideoCall.OriginalDestinationUri, helpdeskExtension);

                        if (audioVideoCall.State == CallState.Established)
                        {
                            audioVideoCall.BeginTransfer(
                                helpdeskExtension,
                                new CallTransferOptions(CallTransferType.Attended),
                                result =>
                            {
                                try
                                {
                                    audioVideoCall.EndTransfer(result);
                                }
                                catch (OperationFailureException ofe)
                                {
                                    this.logger.Log("The recipient declined or did not answer the call:{0}",
                                                    ofe);
                                }
                                catch (RealTimeException rte)
                                {
                                    this.logger.Log("Error transferring call:{0}", rte);
                                }
                            }, null);
                        }
                    }
                    else
                    {
                        this.logger.Log("Unable to find helpdesk number for {0} -> {1}", selectedOptions[0], selectedOptions[1]);
                        TerminateCall();
                    }
                }
                else
                {
                    this.logger.Log("Option Selected are less than 2");
                    TerminateCall();
                }
            }
            else
            {
                this.logger.Log("No user input");
                TerminateCall();
            }
        }
        private void SelfTransferSupervisorCall(AudioVideoCall supervisorCall)
        {
            Console.WriteLine("Self transfering the call.");
            // Put this instance of SupervisorJoinCallSession into the context property for retrieval when the application receives the self-transferred call.
            supervisorCall.Conversation.ApplicationContext = this;

            try
            {
                // Perform a self-transfer
                supervisorCall.BeginTransfer(
                    supervisorCall,
                    transferAsyncResult =>
                    {
                        try
                        {
                            supervisorCall.EndTransfer(transferAsyncResult);
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }