Join a Lync Conference

[This is preliminary documentation and is subject to change.]

The following code examples run on multiple computers. The first computer is used to start a conference using Microsoft Lync 2013 Preview SDK UI Automation and the other computers are used to join the conference started on the first computer.

The first computer starts the conference by calling into the BeginStartConversation method and obtaining a new ConversationWindow instance by calling into the EndStartConversation method. The Conversation property returns the Conversation instance used in the following example.

// Create the major API automation object.
Automation _Automation = LyncClient.GetAutomation();

// Create a generic List object to contain a contact URI and be sure a valid URI is added.
List<string> inviteeList = new List<string>();

// Create a generic Dictionary object to contain conversation setting objects.
Dictionary<AutomationModalitySettings, object> _ModalitySettings = new Dictionary<AutomationModalitySettings, object>();
AutomationModalities _ChosenMode = AutomationModalities.InstantMessage;

_ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, "Weekly project status meeting starts now");
_ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);

// Start the conversation.
IAsyncResult ar = _Automation.BeginStartConversation(
    , invitees
    , _ModalitySettings
    , null
    , null);

// Block UI thread until conversation is started.
ConversationWindow conferenceWindow = _Automation.EndStartConversation(ar);
Conversation conferenceConversationObject = conferenceWindow.Conversation;

// Register for the property changed event to get notification when the 
// ConferenceUri property has been filled.
conferenceConversationObject.PropertyChanged += Conversation_PropertyChanged;

The conference Uri obtained in the preceding example must be passed to users on other computers to allow them to join the new conference. The transfer method is out of scope for this discussion but can include email.

Getting the Conference Uri

The conversation properties that you use to form a complete conference Uri are null at the time the conversation is created. To get the conference uri properties, you register for the Conversation.PropertyChanged event on the conversation. In the PropertyChanged event handler that is raised when any kind of conversation property is changed, you compare the ConversationPropertyChangedEventArgs.Property to Microsoft.Lync.Model.Conversation.ConversationProperty. ConferencingUri. If the values match then the property whose value has changed is the conference uri. You build the conference uri join string as in the following example.

The following example builds a conference join Url using properties of the Conversation.

        /// <summary>
        /// Handles event raised when a property of a conversation has changed
        /// </summary>
        /// <param name="sender">object. The Conversation whose property has changed.</param>
        /// <param name="e">ConversationPropertyChangedEventArgs. The state of the event</param>
        void Conversation_PropertyChanged(object sender, ConversationPropertyChangedEventArgs e)
            if (e.Property == ConversationProperty.ConferencingUri)
                string ConferenceUri = "conf:" 
                    + ((Conversation)sender).Properties[ConversationProperty.ConferencingUri]
                    + "?" + ((Conversation)sender).Properties[ConversationProperty.Id];

Elise and Sam are invited to the conference explicitly because they were added to the invitee list when the conference was started. These two users receive conversation invitations through Microsoft Lync 2013 Preview. Other users who should attend the meeting must get the conference Uri and then join the conference using the Uri.

Once the conference Uri is obtained by another user, use the BeginStartConversation method to join a conference in a Microsoft Lync 2013 Preview SDK application. The string argument of the call is the conference Uri.

Important note Important

The UI thread of this sample is blocked until the user joins the conference. The call into EndStartConversation immediately follows BeginStartConversation, but does not return until the conference is joined. If you do not want to block your UI thread while the joining operation is in progress, pass a callback method into BeginStartConversation and then call EndStartConversation inside of the passed callback method.

IAsyncResult ar = LyncClient.GetAutomation().BeginStartConversation(
    , this.Handle.ToInt32()
    , null
    , null);


Community Additions

© 2015 Microsoft