Esempio n. 1
0
        private void CreateBackToBack()
        {
            Console.WriteLine("Creating a back to back call between caller and the conference.");
            // Create a back to back call between the caller and the conference.
            // This is so the caller will not see that he/she is connected to a conference.
            BackToBackCallSettings frontEndCallLegSettings = new BackToBackCallSettings(_frontEndCallLeg);
            BackToBackCallSettings backEndCallLegSettings = new BackToBackCallSettings(_backEndCallLeg);

            _b2bCall = new BackToBackCall(frontEndCallLegSettings, backEndCallLegSettings);

            try
            {
                // Establish the back to back call.
                _b2bCall.BeginEstablish(
                    establishAsyncResult =>
                    {
                        try
                        {
                            _b2bCall.EndEstablish(establishAsyncResult);
                            Console.WriteLine("Back to back call established.");

                            InviteRecipientToConference();
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 2
0
        public void JoinLocation(AudioVideoCall incomingCall, Location location)
        {
            _location = location;

            // Call Leg 1
            BackToBackCallSettings settings1 = new BackToBackCallSettings(incomingCall);
            // Call Leg 2
            BackToBackCallSettings settings2 = new BackToBackCallSettings(new AudioVideoCall(location.Conversation));

            settings2.CallEstablishOptions = new AudioVideoCallEstablishOptions()
            {
                UseGeneratedIdentityForTrustedConference = true,
                SupportsReplaces = CapabilitySupport.Supported
            };

            // Create and establish the back to back call.
            _b2bCall = new BackToBackCall(settings1, settings2);
            _b2bCall.StateChanged += new EventHandler <BackToBackCallStateChangedEventArgs>(_b2bCall_StateChanged);
            _b2bCall.BeginEstablish(
                ar =>
            {
                try
                {
                    _b2bCall.EndEstablish(ar);

                    EstablishControlCall();
                }
                catch (RealTimeException ex)
                {
                    Log(ex.ToString());
                }
            },
                null);
        }
Esempio n. 3
0
        public void JoinLocation(AudioVideoCall incomingCall, Location location)
        {
            _location = location;

            // Call Leg 1
            BackToBackCallSettings settings1 = new BackToBackCallSettings(incomingCall);
            // Call Leg 2
            BackToBackCallSettings settings2 = new BackToBackCallSettings(new AudioVideoCall(location.Conversation));

            settings2.CallEstablishOptions = new AudioVideoCallEstablishOptions()
            {
                UseGeneratedIdentityForTrustedConference = true,
                SupportsReplaces = CapabilitySupport.Supported
            };

            // Create and establish the back to back call.
            _b2bCall = new BackToBackCall(settings1, settings2);
            _b2bCall.StateChanged += new EventHandler<BackToBackCallStateChangedEventArgs>(_b2bCall_StateChanged);
            _b2bCall.BeginEstablish(
                ar =>
                {
                    try
                    {
                        _b2bCall.EndEstablish(ar);

                        EstablishControlCall();
                    }
                    catch (RealTimeException ex)
                    {
                        Log(ex.ToString());
                    }
                },
                null);
        }
Esempio n. 4
0
        public void Run()
        {
            // Initialize and register the endpoint, using the credentials of the user the application will be acting as.
            _helper       = new UCMASampleHelper();
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("B2BCall Sample User" /*endpointFriendlyName*/);
            _userEndpoint.RegisterForIncomingCall <AudioVideoCall>(inboundAVCall_CallReceived);

            // Conversation settings for the outbound call (to the agent).
            ConversationSettings outConvSettings = new ConversationSettings();

            outConvSettings.Priority = _conversationPriority;
            outConvSettings.Subject  = _outConversationSubject;

            // Create the Conversation instance between UCMA and the agent.
            _outboundConversation = new Conversation(_userEndpoint, outConvSettings);

            // Create the outbound call between UCMA and the agent.
            _outboundAVCall = new AudioVideoCall(_outboundConversation);

            // Register for notification of the StateChanged event on the outbound call.
            _outboundAVCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(outboundAVCall_StateChanged);

            // Prompt for called party - the agent.
            _calledParty = UCMASampleHelper.PromptUser("Enter the URI of the called party, in sip:User@Host form or tel:+1XXXYYYZZZZ form => ", "RemoteUserURI1");

            _outboundCallLeg = new BackToBackCallSettings(_outboundAVCall, _calledParty);

            // Pause the main thread until both calls, the BackToBackCall, both conversations,
            // and the platform are shut down.
            _waitUntilOneUserHangsUp.WaitOne();

            // Pause the console to allow for easier viewing of logs.
            Console.WriteLine("Press any key to end the sample.");
            Console.ReadKey();
        }
Esempio n. 5
0
        /* private void audioVideoFlow_StateChanged(object sender, MediaFlowStateChangedEventArgs e)
         * {
         *  Console.WriteLine("Flow state changed from " + e.PreviousState + " to " + e.State);
         *
         *  // When the flow is active, media operations can begin.
         *  if (e.State == MediaFlowState.Active)
         *  {
         *      // Other samples demonstrate uses for an active flow.
         *  }
         * } */

        // The delegate to be called when the inbound call arrives (the call from a customer).
        private void inboundAVCall_CallReceived(object sender, CallReceivedEventArgs <AudioVideoCall> e)
        {
            _inboundAVCall = e.Call;
            // Register for notification of the StateChanged event on the incoming call.
            _inboundAVCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(inboundAVCall_StateChanged);

            // Create a new conversation for the incoming call leg.
            _inboundConversation = new Conversation(_userEndpoint);

            _inboundCallLeg = new BackToBackCallSettings(_inboundAVCall);

            // Create the back-to-back call instance.
            // Note that you need a Destination URI for the outgoing call leg, but not for the incoming call leg.
            _b2bCall = new BackToBackCall(_inboundCallLeg, _outboundCallLeg);

            // Begin the back-to-back session; provide a destination.
            try
            {
                IAsyncResult result = _b2bCall.BeginEstablish(BeginEstablishCB, _b2bCall);

                /* IAsyncResult result = _b2bCall.BeginEstablish(
                 *  delegate(IAsyncResult ar)
                 * {
                 *  _b2bCall.EndEstablish(ar);
                 *  _waitForB2BCallToEstablish.Set();
                 * }, _b2bCall);*/
            }
            catch (InvalidOperationException ioe)
            {
                Console.WriteLine("_b2bCall must be in the Idle state." + ioe.Message.ToString());
            }
            _waitForB2BCallToEstablish.WaitOne();
        }
Esempio n. 6
0
        /// <summary>
        /// Process incoming audio video call.
        /// </summary>
        /// <param name="avCall"></param>
        public void ProcessIncomingDialOutCall(AudioVideoCall avCall)
        {
            bool      unhandledExceptionOccured = true;
            Exception caughtException           = null;

            try
            {
                BackToBackCallSettings incomingCallSettings = new BackToBackCallSettings(avCall);

                AudioVideoCall         customerCall     = new AudioVideoCall(this.customerConversation);
                BackToBackCallSettings idleCallSettings = new BackToBackCallSettings(customerCall);
                BackToBackCall         b2bCall          = new BackToBackCall(incomingCallSettings, idleCallSettings);

                b2bCall.BeginEstablish(this.BackToBackCallEstablished, b2bCall);

                unhandledExceptionOccured = false;
            }
            catch (InvalidOperationException ioe)
            {
                caughtException = ioe;
                Console.WriteLine("Exception during back to back call establish {0}", ioe);
                this.logger.Log("Exception during back to back call establish {0}", ioe);
                unhandledExceptionOccured = false;
            }
            catch (RealTimeException rte)
            {
                caughtException = rte;
                Console.WriteLine("Exception during back to back call establish {0}", rte);
                this.logger.Log("Exception during back to back call establish {0}", rte);
                unhandledExceptionOccured = false;
            }
            finally
            {
                if (unhandledExceptionOccured)
                {
                    caughtException = new OperationFailureException();
                }

                if (caughtException != null)
                {
                    this.CompleteEstablishment(caughtException);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Places the call in the call queue.
        /// </summary>
        /// <returns></returns>
        public async Task Queue()
        {
            await DisconnectB2B();

            // obtain queue URI
            var queueAddress = await application.Conference.GetConferenceUri();

            // second leg of call to conference
            b2bCall = new AudioVideoCall(new Conversation(call.Conversation.Endpoint));
            b2bCall.Conversation.Impersonate(uri, phoneUri, displayName);
            await b2bCall.Conversation.ConferenceSession.JoinAsync(queueAddress.Uri, null);

            // join first and second leg
            var leg1B2B = new BackToBackCallSettings(call);
            var leg2B2B = new BackToBackCallSettings(b2bCall);

            // establish back to back call
            b2b = new BackToBackCall(leg1B2B, leg2B2B);
            await b2b.EstablishAsync();
        }
        private void CreateSupervisorB2BCall(AudioVideoCall incomingCall, Conversation conferenceConversation)
        {
            Console.WriteLine("Creating a supervisor B2B call.");
            // Create a new audio call on the back-end call leg
            AudioVideoCall callToConference = new AudioVideoCall(conferenceConversation);

            // Set up the call to be automatically removed from the default audio mix in the A/V MCU.
            AudioVideoCallEstablishOptions establishOptions = new AudioVideoCallEstablishOptions();
            establishOptions.AudioVideoMcuDialInOptions.RemoveFromDefaultRouting = true;

            // Create a back to back call between the supervisor and the conference 
            BackToBackCallSettings frontEndB2BSettings = new BackToBackCallSettings(incomingCall);
            BackToBackCallSettings backEndB2BSettings = new BackToBackCallSettings(callToConference);

            backEndB2BSettings.CallEstablishOptions = establishOptions;

            BackToBackCall supervisorB2BCall = new BackToBackCall(frontEndB2BSettings, backEndB2BSettings);

            try
            {
                // Establish the B2B call
                supervisorB2BCall.BeginEstablish(
                    establishAsyncResult =>
                    {
                        try
                        {
                            supervisorB2BCall.EndEstablish(establishAsyncResult);

                            CreateManualAudioRoutes(callToConference);
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }