// Callback method referred to in the call to BeginEscalate on the Conference instance.
        private void ConferenceEscalateCB(IAsyncResult ar)
        {
            Conversation conversation = ar.AsyncState as Conversation;

            try
            {
                conversation.EndEscalateToConference(ar);
            }

            // A production application should have catch blocks for a number
            // of other exceptions, including OperationTimeoutException and
            // OperationFailureException.
            catch (RealTimeException exception)
            {
                Console.WriteLine(exception.ToString());
            }
            // Synchronize with main thread.
            // _waitUntilConferenceIsEscalated.Set();

            ConferenceInvitation conferenceInvite = new ConferenceInvitation(_incomingConversation);

            conferenceInvite.StateChanged += new EventHandler <ConferenceInvitationStateChangedEventArgs>(conferenceInvite_StateChanged);
            ConferenceInvitationDeliverOptions confDeliverOptions = new ConferenceInvitationDeliverOptions();

            confDeliverOptions.ToastMessage = new ToastMessage("Join the conference!");
            conferenceInvite.BeginDeliver(_remoteContactUri.ToString(), confDeliverOptions, InvitationDeliverCB, conferenceInvite);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends a conference invitation to the specified uri.
        /// </summary>
        /// <param name="invitationTargetUri">The uri that the invitation should
        /// be sent to.</param>
        private void InviteUserToConference(string invitationTargetUri)
        {
            ConferenceInvitation confInvitation = new ConferenceInvitation(_impersonatingAvCall.Conversation);
            ConferenceInvitationDeliverOptions deliverOptions = new ConferenceInvitationDeliverOptions();

            const string sipPrefix = "sip:";

            if (!invitationTargetUri.Trim().StartsWith(sipPrefix, StringComparison.OrdinalIgnoreCase))
            {
                invitationTargetUri = sipPrefix + invitationTargetUri.Trim();
            }

            Console.WriteLine("Inviting {0} to the conference.", invitationTargetUri);
            _invitedParticipantAccepted = false;
            var confInvitationResult = confInvitation.BeginDeliver(invitationTargetUri,
                                                                   deliverOptions,
                                                                   ConfInvitationCompleted,
                                                                   confInvitation);

            Console.WriteLine("Waiting for the conference invitation to complete.");
            _conferenceInvitationCompleted.WaitOne();

            Console.WriteLine("Finished inviting {0} to the conference.", invitationTargetUri);
            Console.WriteLine();
        }
Exemplo n.º 3
0
 private void SendConferenceInvitation(AsyncTask task, object state)
 {
     task.DoOneStep(
         delegate()
     {
         string uriToDialOutTo     = (string)state;
         McuDialOutOptions options = new McuDialOutOptions();
         options.Issuer            = this.CustomerSession.CustomerConversation.LocalParticipant;
         ConferenceInvitationSettings convSettings = new ConferenceInvitationSettings();
         convSettings.AvailableMediaTypes.Add(MediaType.Audio);
         var confInvitation = new ConferenceInvitation(this.CustomerSession.CustomerConversation, convSettings);
         this.StartMusic();
         confInvitation.BeginDeliver(
             uriToDialOutTo,
             delegate(IAsyncResult ar)
         {
             task.DoFinalStep(
                 delegate()
             {
                 this.StopMusic();
                 confInvitation.EndDeliver(ar);
             });
         },
             null);
     });
 }
Exemplo n.º 4
0
        private void InviteToConference(string uri, CompletionDelegate completionDelegate)
        {
            Debug.Assert(!string.IsNullOrEmpty(uri), "New user could not be null.");

            ConferenceInvitationSettings convSettings = new ConferenceInvitationSettings();

            convSettings.AvailableMediaTypes.Add(MediaType.Audio);
            var confInvitation = new ConferenceInvitation(this.CustomerSession.CustomerConversation, convSettings);

            try
            {
                if (this.CustomerSession.RosterTrackingService.ParticipantCount == 1)
                {
                    this.StartMusic(this.CustomerSession.CustomerServiceChannel.ServiceChannelCall);
                }
                confInvitation.BeginDeliver(
                    uri,
                    ar =>
                {
                    try
                    {
                        confInvitation.EndDeliver(ar);
                        completionDelegate(null);
                    }
                    catch (RealTimeException rte)
                    {
                        this.StopMusic(this.CustomerSession.CustomerServiceChannel.ServiceChannelCall);
                        completionDelegate(rte);
                    }
                }, null);
            }
            catch (InvalidOperationException ioe)
            {
                this.Logger.Log(Logger.LogLevel.Error, ioe);
                this.StopMusic(this.CustomerSession.CustomerServiceChannel.ServiceChannelCall);
                completionDelegate(ioe);
            }
        }
Exemplo n.º 5
0
        private void InviteRecipientToConference()
        {
            Console.WriteLine("Inviting the recipient (" + _recipientSipUri + ") to incoming call.");
            ConferenceInvitation invitation = new ConferenceInvitation(_backEndCallLeg.Conversation);

            try
            {
                // Invite the recipient to the conference using a conference invitation.
                invitation.BeginDeliver(
                    _recipientSipUri,
                    deliverAsyncResult =>
                    {
                        try
                        {
                            invitation.EndDeliver(deliverAsyncResult);
                            Console.WriteLine("Invited recipient to the conference.");
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine(ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 6
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.
            _callerEndpoint = _helper.CreateEstablishedUserEndpoint(
                "Conference Leader" /* friendly name for conference leader endpoint */);

            // Create a second user endpoint, using the network credential object
            // defined above.
            _calleeEndpoint = _helper.CreateEstablishedUserEndpoint(
                "Conference Attendee" /* friendly name for conference attendee endpoint */);

            // Get the URI for the user logged onto Microsoft Lync
            String _ocUserURI = "sip:" + UCMASampleHelper.PromptUser(
                "Enter the URI for the user logged onto Microsoft Lync, in the User@Host format => ",
                "RemoteUserURI" /* key to specify remote user's URI in app.config */);

            // One of the endpoints schedules the conference in advance. At
            // schedule time, all the conference settings are set.

            // The base conference settings object, used to set the policies for the conference.
            ConferenceScheduleInformation conferenceScheduleInformation = new ConferenceScheduleInformation();

            // An open meeting (participants can join who are not on the list),
            // but requiring authentication (no anonymous users allowed.)
            conferenceScheduleInformation.AccessLevel = ConferenceAccessLevel.SameEnterprise;
            // The below flag determines whether or not the passcode is optional
            // for users joining the conference.
            conferenceScheduleInformation.IsPasscodeOptional = true;
            conferenceScheduleInformation.Passcode           = "1357924680";
            // The verbose description of the conference
            conferenceScheduleInformation.Description = "Interesting Description";
            // The below field indicates the date and time after which the conference can be deleted.
            conferenceScheduleInformation.ExpiryTime = System.DateTime.Now.AddHours(5);

            // These two lines assign a set of modalities (here, only
            // InstantMessage) from the available MCUs to the conference. Custom
            // modalities (and their corresponding MCUs) may be added at this
            // time as part of the extensibility model.
            ConferenceMcuInformation instantMessageMCU = new ConferenceMcuInformation(McuType.InstantMessaging);

            conferenceScheduleInformation.Mcus.Add(instantMessageMCU);

            // Now that the setup object is complete, schedule the conference
            // using the conference services off of Endpoint. Note: the conference
            // organizer is considered a leader of the conference by default.
            _callerEndpoint.ConferenceServices.BeginScheduleConference(conferenceScheduleInformation,
                                                                       EndScheduleConference, _callerEndpoint.ConferenceServices);

            // Wait for the scheduling to complete.
            _waitForConferenceScheduling.WaitOne();

            // Now that the conference is scheduled, it's time to join it. As we
            // already have a reference to the conference object populated from
            // the EndScheduleConference call, we do not need to get the
            // conference first. Initialize a conversation off of the endpoint,
            // and join the conference from the uri provided above.
            Conversation callerConversation = new Conversation(_callerEndpoint);

            callerConversation.ConferenceSession.StateChanged += new
                                                                 EventHandler <StateChangedEventArgs <ConferenceSessionState> >(ConferenceSession_StateChanged);

            // Join and wait, again forcing synchronization.
            callerConversation.ConferenceSession.BeginJoin(_conference.ConferenceUri, null /*joinOptions*/,
                                                           EndJoinConference, callerConversation.ConferenceSession);
            _waitForConferenceJoin.WaitOne();

            // Placing the calls on the conference-connected conversation
            // connects to the respective MCUs. These calls may then be used to
            // communicate with the conference/MCUs.
            InstantMessagingCall instantMessagingCall = new InstantMessagingCall(callerConversation);

            // Hooking up event handlers and then placing the call.
            instantMessagingCall.InstantMessagingFlowConfigurationRequested +=
                this.instantMessagingCall_InstantMessagingFlowConfigurationRequested;
            instantMessagingCall.StateChanged += this._call_StateChanged;
            instantMessagingCall.BeginEstablish(EndCallEstablish, instantMessagingCall);

            //Synchronize to ensure that call has completed.
            _waitForCallEstablish.WaitOne();

            //send conf invite
            ConferenceInvitationDeliverOptions deliverOptions = new ConferenceInvitationDeliverOptions();

            deliverOptions.ToastMessage = new ToastMessage("Welcome to my conference");

            ConferenceInvitation invitation = new ConferenceInvitation(callerConversation);

            invitation.BeginDeliver(_ocUserURI, deliverOptions, EndDeliverInvitation, invitation);

            // Synchronize to ensure that invitation is complete
            _waitForConversationInviteRemoteParticipants.WaitOne();

            //And from the other endpoint's perspective:
            //Initialize a conversation off of the endpoint, and join the
            //conference from the uri provided above.
            Conversation calleeConversation = new Conversation(_calleeEndpoint);

            calleeConversation.ConferenceSession.StateChanged += new
                                                                 EventHandler <StateChangedEventArgs <ConferenceSessionState> >(ConferenceSession_StateChanged);

            // Join and wait, again forcing synchronization.
            calleeConversation.ConferenceSession.BeginJoin(_conference.ConferenceUri, null /*joinOptions*/,
                                                           EndJoinConference, calleeConversation.ConferenceSession);
            _waitForConferenceJoin.WaitOne();

            // Placing the calls on the conference-connected conversation
            // connects to the respective MCUs. These calls may then be used to
            //communicate with the conference/MCUs.
            InstantMessagingCall instantMessagingCall2 = new InstantMessagingCall(calleeConversation);

            //Hooking up event handlers and then placing the call.
            instantMessagingCall2.InstantMessagingFlowConfigurationRequested +=
                this.instantMessagingCall2_InstantMessagingFlowConfigurationRequested;
            instantMessagingCall2.StateChanged += this._call_StateChanged;
            instantMessagingCall2.BeginEstablish(EndCallEstablish, instantMessagingCall2);

            //Synchronize to ensure that call has completed.
            _waitForCallEstablish.WaitOne();

            //Synchronize to ensure that all messages are sent and received
            _waitForMessageReceived.WaitOne();

            //Wait for shutdown initiated by user
            _waitForShutdown.WaitOne();

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