Ejemplo n.º 1
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.º 2
0
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and
            // cleanup. This has been abstracted from this sample to focus on
            // Call Control.
            _helper = new UCMASampleHelper();

            // Create a user endpoint, using the network credential object
            // defined above.
            _transferorEndpoint = _helper.CreateEstablishedUserEndpoint("Transferor" /*endpointFriendlyName*/);


            // Get the URI of the user to transfer the call to.
            // Prepend URI with "sip:" if not present.
            _transferTargetUri = UCMASampleHelper.PromptUser("Enter a URI of the user to transfer the call to: ", "TransferTargetUri");
            if (!(_transferTargetUri.ToLower().StartsWith("sip:") || _transferTargetUri.ToLower().StartsWith("tel:")))
            {
                _transferTargetUri = "sip:" + _transferTargetUri;
            }


            // Here, we are accepting an AudioVideo call only. If the incoming
            // call is not an AudioVideo call then it will not get raised to the
            // application. UCMA 3.0 handles this silently by having the call
            // types register for various modalities (as part of the extensibility
            // framework). The appropriate action (here, accepting the call)
            // will be handled in the handler assigned to the method call below.
            _transferorEndpoint.RegisterForIncomingCall <AudioVideoCall>(On_AudioVideoCall_Received);

            // Wait for the call to complete accept.
            Console.WriteLine(String.Empty);
            Console.WriteLine("Transferor waiting for incoming call...");
            _waitForCallAccept.WaitOne();
            Console.WriteLine("Initial call accepted by Transferor.");

            // Then transfer the call to another user, as designated above.
            _audioVideoCall.BeginTransfer(_transferTargetUri, EndTransferCall, _audioVideoCall);
            Console.WriteLine("Waiting for transfer to complete...");

            // Wait for the call to complete the transfer.
            _waitForTransferComplete.WaitOne();
            Console.WriteLine("Transfer completed.");

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

            // Now that the call has completed, shutdown the platform.
            _helper.ShutdownPlatform();
        }
Ejemplo n.º 3
0
        private void TransferringCallEstablishCompleted(IAsyncResult ar)
        {
            AudioVideoCall    call = ar.AsyncState as AudioVideoCall;
            RealTimeException ex   = null;

            try
            {
                call.EndEstablish(ar);
                Console.WriteLine("");
                Console.WriteLine("Now beginning the transfer...");
                Console.WriteLine("");

                // Now that both calls are connected and have been accepted by
                // the called participant, we can use the transferor endpoint to
                // transfer the call from the initial to the final. Note that the
                // transferor endpoint retains it's position of control over both
                // calls. This form of transfer is most suitable for a proxy
                // application, where the proxying agent needs to remain in the
                // signaling channel (For instance, for quality assurance purposes.)
                call.BeginTransfer(_avCallTransferringtoInitial, TransferCallCompleted, call);
                Console.WriteLine("The call with Local Participant: " + call.Conversation.LocalParticipant +
                                  " and Remote Participant: " + call.RemoteEndpoint.Participant +
                                  " is now in the established state.");
            }
            catch (OperationFailureException opFailEx)
            {
                // OperationFailureException: Indicates failure to connect the
                // call to the remote party.
                // TODO (Left to the reader): Add error handling code here.
                ex = opFailEx;
            }
            catch (RealTimeException exception)
            {
                // RealTimeException may be thrown on media or link-layer failures.
                // TODO (Left to the reader): Add error handling code here.
                ex = exception;
            }
            finally
            {
                if (ex != null)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Terminating the application due to failure");
                    _sampleCompleted.Set();
                }
            }
        }
        /// <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));
                }
            }
        }
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);
            }
        }