private async Task CreateConference()
 {
     _confConversation = new Conversation(_endpoint);
     var options = new ConferenceJoinOptions() { JoinMode = JoinMode.TrustedParticipant, AdHocConferenceAccessLevel = ConferenceAccessLevel.Everyone, AdHocConferenceAutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone };
     await _confConversation.ConferenceSession.JoinAsync(options);
     Console.WriteLine("New conference created");
 }
Пример #2
0
        /// <summary>
        /// This function creates an ad-hoc conference and joins as a trusted
        /// participant. Anytime a new participant to the conference is
        /// detected, a new AV call will be created to route audio to that user
        /// and receive DTMF from them. When a DTMF digit is detected, an
        /// utterance of the detected digit will be played back to that user
        /// such that they are the only ones that hear it.
        /// </summary>
        private void JoinConferenceAsTrustedParticipant()
        {
            Console.WriteLine("Joining the conference as a Trusted Participant.");

            //Create a new conversation for the application endpoint.
            _trustedParticipantConversation = new Conversation(_appEndpoint);

            ConferenceJoinOptions confJoinOptions = new ConferenceJoinOptions();

            // Set the app endpoint to join the conference as a trusted
            // participant which will result in it being hidden on the roster
            // as well as execute conference commands on behalf of other
            // participants.
            confJoinOptions.JoinMode = JoinMode.TrustedParticipant;

            //Join the conference
            _trustedParticipantConversation.ConferenceSession.BeginJoin(_conferenceUri, confJoinOptions,
                                                                        TrustedParticipantConferenceJoinCompleted, _trustedParticipantConversation.ConferenceSession);


            //Wait for the trusted participant to create and join the ad-hoc
            // conference.
            Console.WriteLine("Waiting for the conference join to complete.");
            _trustedParticipantConferenceJoinCompleted.WaitOne();
        }
 public static Task JoinAsync(this ConferenceSession self, ConferenceJoinOptions options)
 {
     return Task.Factory.FromAsync<ConferenceJoinOptions>(
         self.BeginJoin,
         self.EndJoin,
         options,
         null);
 }
Пример #4
0
        private async Task CreateConference()
        {
            _confConversation = new Conversation(_endpoint);
            var options = new ConferenceJoinOptions()
            {
                JoinMode = JoinMode.TrustedParticipant, AdHocConferenceAccessLevel = ConferenceAccessLevel.Everyone, AdHocConferenceAutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone
            };
            await _confConversation.ConferenceSession.JoinAsync(options);

            Console.WriteLine("New conference created");
        }
Пример #5
0
        protected void StartupJoinConference(AsyncTask task, object state)
        {
            task.DoOneStep(
                delegate()
            {
                Conference conference = null;
                AsyncTaskResult conferenceActionResult = task.PreviousActionResult;
                // Normally, the previous task should be the one that scheduled the conference. But, play safe to allow other actions in between.
                while (conferenceActionResult != null)
                {
                    ConferenceActionResult conferenceResult = conferenceActionResult as ConferenceActionResult;
                    if (conferenceResult != null)
                    {
                        conference = conferenceResult.Conference;
                        break;
                    }
                    conferenceActionResult = conferenceActionResult.PreviousActionResult;
                }
                if (conference == null)
                {
                    task.Complete(new InvalidOperationException("StartupConferenceJoin: Conference must be scheduled before conference join operation."));
                    return;
                }
                ConferenceJoinOptions options = new ConferenceJoinOptions();
                options.JoinMode = JoinMode.TrustedParticipant;

                m_tcuConversation.ConferenceSession.BeginJoin(
                    conference.ConferenceUri,
                    options,
                    delegate(IAsyncResult ar)
                {
                    task.DoFinalStep(
                        delegate()
                    {
                        m_tcuConversation.ConferenceSession.EndJoin(ar);
                        this.Logger.Log(Logger.LogLevel.Verbose,
                                        String.Format("ServiceHub {0} joined TCU conference {1}.",
                                                      this.CustomerSession.Customer.UserUri,
                                                      m_tcuConversation.ConferenceSession.ConferenceUri));
                    });
                },
                    null);
            });
        }
Пример #6
0
        /// <summary>
        /// Conference scheduled callback.
        /// </summary>
        /// <param name="asyncResult"></param>
        private void ConferenceScheduled(IAsyncResult asyncResult)
        {
            ConferenceServices conferenceManagement = asyncResult.AsyncState as ConferenceServices;

            bool      unhandledExceptionOccured = true;
            Exception caughtException           = null;

            try
            {
                conferenceManagement.EndScheduleConference(asyncResult);

                ConferenceJoinOptions options = new ConferenceJoinOptions();
                this.trustedConversation.ConferenceSession.BeginJoin(options, this.ConferenceJoinCompleted, null);

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

                if (caughtException != null)
                {
                    this.CompleteEstablishment(caughtException);
                }
            }
        }
        public void ConferenceInviteAccepted(IAsyncResult result)
        {
            try
            {
                ConferenceInvitation invite = result.AsyncState as ConferenceInvitation;
                // ConferenceInvite already accepted in TranscriptRecorder.ConferenceInvitation_AcceptCompleted()

                Message m = new Message("ConferenceSession.ConferenceInviteAccepted()",
                   MessageType.ConferenceInfo, _conversation.Id, invite.ConferenceUri);
                _transcriptRecorder.OnMessageReceived(m);

                ConferenceJoinOptions cjo = new ConferenceJoinOptions();
                //cjo.JoinAsTrustedApplication = false;
                _conversation.ConferenceSession.BeginJoin(cjo, EndJoinInvitedConference, invite);
            }
            catch (RealTimeException ex)
            {
                NonBlockingConsole.WriteLine("invite.EndAccept failed. Exception: {0}", ex.ToString());
            }
            catch (InvalidOperationException ex)
            {
                NonBlockingConsole.WriteLine("m_conversation.ConferenceSession.BeginJoin failed. Exception: {0}", ex.ToString());
            }
        }
        public void ConferenceInviteAccepted(IAsyncResult result)
        {
            try
            {
                ConferenceInvitation invite = result.AsyncState as ConferenceInvitation;
                // ConferenceInvite already accepted in TranscriptRecorder.ConferenceInvitation_AcceptCompleted()

                Message m = new Message("ConferenceSession.ConferenceInviteAccepted()",
                                        MessageType.ConferenceInfo, _conversation.Id, invite.ConferenceUri);
                _transcriptRecorder.OnMessageReceived(m);

                ConferenceJoinOptions cjo = new ConferenceJoinOptions();
                //cjo.JoinAsTrustedApplication = false;
                _conversation.ConferenceSession.BeginJoin(cjo, EndJoinInvitedConference, invite);
            }
            catch (RealTimeException ex)
            {
                NonBlockingConsole.WriteLine("invite.EndAccept failed. Exception: {0}", ex.ToString());
            }
            catch (InvalidOperationException ex)
            {
                NonBlockingConsole.WriteLine("m_conversation.ConferenceSession.BeginJoin failed. Exception: {0}", ex.ToString());
            }
        }
Пример #9
0
            internal void Process()
            {
                if (String.IsNullOrEmpty(_anchor._conferenceUri))
                {
                    _anchor.AuthorizeParticipant(_presenterUri);
                    _anchor.ElevateToPresenter(_presenterUri);

                    ConferenceServices conferenceManagement = _anchor._endpoint.ConferenceServices;

                    //Create a conference to anchor the incoming customer call
                    ConferenceScheduleInformation conferenceScheduleInfo = new ConferenceScheduleInformation();
                    conferenceScheduleInfo.AutomaticLeaderAssignment = AutomaticLeaderAssignment.Disabled;
                    conferenceScheduleInfo.LobbyBypass        = LobbyBypass.Disabled;
                    conferenceScheduleInfo.AccessLevel        = ConferenceAccessLevel.Locked;
                    conferenceScheduleInfo.PhoneAccessEnabled = false;
                    conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(MediaType.ApplicationSharing));
                    conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo));
                    conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(McuType.InstantMessaging));

                    try
                    {
                        //schedule the conference
                        conferenceManagement.BeginScheduleConference(conferenceScheduleInfo,
                                                                     ar =>
                        {
                            try
                            {
                                _anchor._conference = conferenceManagement.EndScheduleConference(ar);
                            }
                            catch (RealTimeException rtex)
                            {
                                this.SetAsCompleted(rtex, false);
                                return;
                            }
                            _anchor._conferenceUri = _anchor._conference.ConferenceUri;
                            _anchor.RegisterForEvents();

                            //Join the conference as a trusted conferencing user (invisible in the roster)
                            ConferenceJoinOptions options = new ConferenceJoinOptions();
                            options.JoinMode = JoinMode.TrustedParticipant;


                            try
                            {
                                _anchor._conversation.ConferenceSession.BeginJoin(_anchor._conference.ConferenceUri,
                                                                                  options,
                                                                                  jar =>
                                {
                                    Conversation conv = jar.AsyncState as Conversation;
                                    try
                                    {
                                        conv.ConferenceSession.EndJoin(jar);

                                        //Update the state of the anchor when the operation succeeds
                                        _anchor.UpdateState(ConferenceServicesAnchorState.Established);

                                        this.SetAsCompleted(null, false);
                                    }
                                    catch (RealTimeException rtex)
                                    {
                                        if (null != _anchor)
                                        {
                                            _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", rtex);
                                        }
                                        _anchor.BeginShutDown(sar =>
                                        {
                                            AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor;
                                            anchor.EndShutDown(sar);
                                        },
                                                              _anchor);
                                        this.SetAsCompleted(rtex, false);
                                    }
                                }
                                                                                  , _anchor._conversation);
                            }
                            catch (InvalidOperationException ivoex)
                            {
                                _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", ivoex);
                                _anchor.BeginShutDown(sar =>
                                {
                                    AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor;
                                    anchor.EndShutDown(sar);
                                },
                                                      _anchor);
                                this.SetAsCompleted(new OperationFailureException("AcdConferenceServicesAnchor failed creating a conference", ivoex), false);
                            }
                        },
                                                                     conferenceManagement);
                    }
                    catch (InvalidOperationException ivoex)
                    {
                        _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", ivoex);
                        _anchor.BeginShutDown(sar =>
                        {
                            AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor;
                            anchor.EndShutDown(sar);
                        },
                                              _anchor);
                        this.SetAsCompleted(new OperationFailureException("AcdConferenceServicesAnchor failed to create a conference", ivoex), false);
                    }
                }
                else
                {
                    _anchor.RegisterForEvents();

                    ConferenceJoinOptions options = new ConferenceJoinOptions();
                    options.JoinMode = JoinMode.TrustedParticipant;


                    try
                    {
                        _anchor._conversation.ConferenceSession.BeginJoin(_anchor._conferenceUri,
                                                                          options,
                                                                          jar =>
                        {
                            Conversation conv = jar.AsyncState as Conversation;
                            try
                            {
                                conv.ConferenceSession.EndJoin(jar);
                                _anchor.UpdateState(ConferenceServicesAnchorState.Established);
                                this.SetAsCompleted(null, false);
                            }
                            catch (RealTimeException rtex)
                            {
                                if (null != _anchor)
                                {
                                    _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", rtex);
                                }
                                _anchor.BeginShutDown(sar =>
                                {
                                    AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor;
                                    anchor.EndShutDown(sar);
                                },
                                                      _anchor);
                                this.SetAsCompleted(rtex, false);
                            }
                        },
                                                                          _anchor._conversation);
                    }
                    catch (InvalidOperationException ivoex)
                    {
                        _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", ivoex);
                        _anchor.BeginShutDown(sar =>
                        {
                            AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor;
                            anchor.EndShutDown(sar);
                        },
                                              _anchor);
                        this.SetAsCompleted(new OperationFailureException("AcdConferenceServicesAnchor failed to create a conference", ivoex), false);
                    }
                }
            }
Пример #10
0
        public Location(int id, string name, string fileName, LocalEndpoint endpoint)
        {
            if (!File.Exists(fileName))
                throw new FileNotFoundException(fileName);

            _id = id;
            _Name = name;
            _FileName = fileName;
            _Endpoint = endpoint;

            ConferenceScheduleInformation csi = new ConferenceScheduleInformation()
            {
                AccessLevel = ConferenceAccessLevel.Everyone,
                Description = _Name,
                ExpiryTime = DateTime.Now.AddYears(5),
                AutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone
            };

            csi.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo));

            _Endpoint.ConferenceServices.BeginScheduleConference(csi,
                ar =>
                {
                    try
                    {
                        _conference = _Endpoint.ConferenceServices.EndScheduleConference(ar);

                        Log("Conference " + _conference.ConferenceId + " scheduled. Starting music...");

                        Log(_conference.ConferenceUri);

                        ConversationSettings cs = new ConversationSettings()
                        {
                            Subject = _Name
                        };

                        _conversation = new Conversation(_Endpoint, cs);

                        ConferenceJoinOptions cjo = new ConferenceJoinOptions()
                        {
                            JoinMode = JoinMode.TrustedParticipant
                        };

                        _conversation.ConferenceSession.BeginJoin(_conference.ConferenceUri,
                            cjo,
                            ar1 =>
                            {
                                try
                                {
                                    _conversation.ConferenceSession.EndJoin(ar1);

                                    _avCall = new AudioVideoCall(_conversation);
                                    _avCall.AudioVideoFlowConfigurationRequested +=
                                        new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(_avCall_AudioVideoFlowConfigurationRequested);

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

                                    _avCall.BeginEstablish(
                                        options,
                                        ar2 =>
                                        {
                                            try
                                            {
                                                _avCall.EndEstablish(ar2);
                                            }
                                            catch (Exception ex)
                                            {
                                                Log(ex.ToString());
                                            }
                                        },
                                        null);
                                }
                                catch (Exception ex)
                                {
                                    Log(ex.ToString());
                                }
                            },
                            null);
                    }
                    catch (Exception ex)
                    {
                        Log(ex.ToString());
                    }
                },
                null);
        }
 public static Task JoinAsync(this ConferenceSession session,
     string conferenceUri, ConferenceJoinOptions options)
 {
     return Task.Factory.FromAsync(session.BeginJoin,
         session.EndJoin, conferenceUri, options, null);
 }
 /// <summary>
 /// Join Conference and start TranscriptRecorderSession on Conference
 /// </summary>
 /// <param name="conferenceUri"></param>
 /// <param name="options"></param>
 public async Task StartConferenceTranscriptRecorderSession(string conferenceUri, ConferenceJoinOptions options = null)
 {
     throw new NotImplementedException("StartConferenceTranscriptRecorderSession is not yet implemented");
 }
Пример #13
0
 /// <summary>
 /// Join Conference and start TranscriptRecorderSession on Conference
 /// </summary>
 /// <param name="conferenceUri"></param>
 /// <param name="options"></param>
 public async Task StartConferenceTranscriptRecorderSession(string conferenceUri, ConferenceJoinOptions options = null)
 {
     throw new NotImplementedException("StartConferenceTranscriptRecorderSession is not yet implemented");
 }
Пример #14
0
        // Escalate call to a conference
        public void EscalateCalltoConference(AudioVideoCall call, string recipient)
        {
            _frontEndCallLeg = call;
            _recipient = recipient;

            Console.WriteLine("Escalating incoming call to conference");
            LocalEndpoint localEndpoint = _frontEndCallLeg.Conversation.Endpoint;
            Conversation backEndConversation = new Conversation(localEndpoint);

            string callerSipUri = _frontEndCallLeg.RemoteEndpoint.Participant.Uri;
            backEndConversation.Impersonate(callerSipUri, null, null);
            Console.WriteLine("Caller SIP Uri: " + callerSipUri);

            try
            {
                ConferenceJoinOptions options = new ConferenceJoinOptions();
                options.JoinMode = JoinMode.TrustedParticipant;

                backEndConversation.ConferenceSession.BeginJoin(
                    options,
                    joinAsyncResult =>
                    {
                        try
                        {
                            backEndConversation.ConferenceSession.EndJoin(joinAsyncResult);
                            Console.WriteLine("Joined conference.");
                            _backEndCallLeg = new AudioVideoCall(backEndConversation);
                            CreateBackToBackCall();
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine("Failed to join conference when escalating the call.\n{0}", ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine("Failed to escalate call to conference: {0}", ex);
            }
        }
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and cleanup.
            _helper = new UCMASampleHelper();

            // Create and establish a user endpoint using the user’s network credentials.
            _userEndpoint = _helper.CreateEstablishedUserEndpoint(
                "FindContact Sample User" /* endpointFriendlyName */);

            // Register a delegate to be called when an incoming InstantMessagingCall arrives.
            _userEndpoint.RegisterForIncomingCall <InstantMessagingCall>(InstantMessagingCall_Received);

            Console.WriteLine("Waiting for an incoming instant messaging call...");
            int ThreadID = Thread.CurrentThread.ManagedThreadId;

            Console.WriteLine("Main thread: ID " + ThreadID);
            // Pause main thread until an incoming call arrives and is accepted.
            _waitUntilIncomingCallIsAccepted.WaitOne();

            InstantMessagingFlow imFlow = _instantMessagingCall.Flow;

            imFlow.BeginSendInstantMessage("Press 1 for Service Department.\n" +
                                           "Press 2 for Sales Department.", CallSendInstantMessageCB, _instantMessagingCall);
            imFlow.MessageReceived += new EventHandler <InstantMessageReceivedEventArgs>(IMFlow_MessageReceived);
            _waitForAvailableTarget.WaitOne();

            if (_remoteContactUri != null)
            {
                imFlow.BeginSendInstantMessage("Contact found: " + _remoteContactUri.ToString(), CallSendInstantMessageCB, _instantMessagingCall);
                // Join the conversation to the IM MCU.
                _conferenceSession = _incomingConversation.ConferenceSession;
                ConferenceJoinOptions confJoinOptions = new ConferenceJoinOptions();
                confJoinOptions.JoinMode = JoinMode.Default;
                _conferenceSession.BeginJoin(confJoinOptions, ConferenceJoinCB, _conferenceSession);

                ThreadID = Thread.CurrentThread.ManagedThreadId;
                Console.WriteLine("Main thread: ID " + ThreadID);
                _waitUntilConferenceInvitationIsDelivered.WaitOne();
            }
            else
            {
                Console.WriteLine("Could not find an available contact.");
                imFlow.BeginSendInstantMessage("Could not find an available contact.\nPlease call again later.", CallSendInstantMessageCB, _instantMessagingCall);
            }
            // Unregister for notification of the MessageReceived event.
            imFlow.MessageReceived -= new EventHandler <InstantMessageReceivedEventArgs>(IMFlow_MessageReceived);
            // Cancel the subscription to the presence session by unsubscribing.
            _userEndpoint.ContactGroupServices.BeginUnsubscribe(ContactGroupUnsubscribeCB, _userEndpoint.ContactGroupServices);
            _remotePresenceView.BeginTerminate(ViewTerminateCB, _remotePresenceView);
            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shut down and exit.");

            // Terminate the call, the conversation, and then unregister the
            // endpoint from receiving an incoming call. Terminating these
            // additional objects individually is made redundant by shutting down
            // the platform right after, but in the multiple call case, this is
            // needed for object hygiene. Terminating a Conversation terminates
            // all its associated calls, and terminating an endpoint
            // terminates all conversations on that endpoint.
            _instantMessagingCall.BeginTerminate(CallTerminateCB, _instantMessagingCall);
            _waitUntilConversationIsTerminated.WaitOne();
            _userEndpoint.UnregisterForIncomingCall <InstantMessagingCall>(InstantMessagingCall_Received);

            // Clean up by shutting down the platform.
            _helper.ShutdownPlatform();
        }
Пример #16
0
        public Location(int id, string name, string fileName, LocalEndpoint endpoint)
        {
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(fileName);
            }

            _id       = id;
            _Name     = name;
            _FileName = fileName;
            _Endpoint = endpoint;

            ConferenceScheduleInformation csi = new ConferenceScheduleInformation()
            {
                AccessLevel = ConferenceAccessLevel.Everyone,
                Description = _Name,
                ExpiryTime  = DateTime.Now.AddYears(5),
                AutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone
            };

            csi.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo));

            _Endpoint.ConferenceServices.BeginScheduleConference(csi,
                                                                 ar =>
            {
                try
                {
                    _conference = _Endpoint.ConferenceServices.EndScheduleConference(ar);

                    Log("Conference " + _conference.ConferenceId + " scheduled. Starting music...");

                    Log(_conference.ConferenceUri);

                    ConversationSettings cs = new ConversationSettings()
                    {
                        Subject = _Name
                    };

                    _conversation = new Conversation(_Endpoint, cs);

                    ConferenceJoinOptions cjo = new ConferenceJoinOptions()
                    {
                        JoinMode = JoinMode.TrustedParticipant
                    };

                    _conversation.ConferenceSession.BeginJoin(_conference.ConferenceUri,
                                                              cjo,
                                                              ar1 =>
                    {
                        try
                        {
                            _conversation.ConferenceSession.EndJoin(ar1);

                            _avCall = new AudioVideoCall(_conversation);
                            _avCall.AudioVideoFlowConfigurationRequested +=
                                new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(_avCall_AudioVideoFlowConfigurationRequested);

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

                            _avCall.BeginEstablish(
                                options,
                                ar2 =>
                            {
                                try
                                {
                                    _avCall.EndEstablish(ar2);
                                }
                                catch (Exception ex)
                                {
                                    Log(ex.ToString());
                                }
                            },
                                null);
                        }
                        catch (Exception ex)
                        {
                            Log(ex.ToString());
                        }
                    },
                                                              null);
                }
                catch (Exception ex)
                {
                    Log(ex.ToString());
                }
            },
                                                                 null);
        }
 public static Task JoinAsync(this ConferenceSession session,
                              string conferenceUri, ConferenceJoinOptions options)
 {
     return(Task.Factory.FromAsync(session.BeginJoin,
                                   session.EndJoin, conferenceUri, options, null));
 }
        internal void HandleIncomingSelfTransfer(AudioVideoCall call)
        {
            Console.WriteLine("Handling the incoming self transfer call.");
            string conferenceUri = _backEndCallLeg.Conversation.ConferenceSession.ConferenceUri;

            // Create a new conversation for the back-end call leg.
            LocalEndpoint localEndpoint = _backEndCallLeg.Conversation.Endpoint;
            Conversation conferenceConversation = new Conversation(localEndpoint);

            // Prepare to join the conference as a trusted participant so as to be allowed to manipulate audio routing.
            ConferenceJoinOptions joinOptions = new ConferenceJoinOptions();
            joinOptions.JoinMode = JoinMode.TrustedParticipant;

            try
            {
                // Join the conference
                conferenceConversation.ConferenceSession.BeginJoin(conferenceUri,
                    joinOptions,
                    joinAsyncResult =>
                    {
                        try
                        {
                            conferenceConversation.ConferenceSession.EndJoin(joinAsyncResult);

                            CreateSupervisorB2BCall(call, conferenceConversation);
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }