Learn about how the Microsoft Lync 2013 SDK ConversationManager class lets you start new conversations and online meetings.
Applies to: Lync 2013 | Lync Server 2013
The Microsoft.Lync.Model.Conversation.ConversationManager class encapsulates the collection of conversations that are starting, currently active, or terminating on the Lync 2013 client. The ConversationManager class is used to start new conversations, join conversations, or join online meetings. It is the source of conversation or meeting invitations when the local user is invited to join conversations that are started by another user. ConversationManager is the factory object that creates a new Microsoft.Lync.Model.Conversation.Conversation object for each conversation that the local user participates in, whether initiated locally or invited remotely. Obtain the ConversationManager object by reading the Client.ConversationManager property.
There are several actions that add a conversation to the conversation collection from the ConversationManager.Conversations property. These actions include the following:
The user starts a new conversation from the Lync 2013 client itself.
The user starts a new conversation by using any of the conversation-initiating Lync Controls that might be populated in your WPF or Silverlight application.
Another user invites the local user to a conversation or online meeting.
The ConversationManager.AddConversation method is called in your application.
The ConversationManager.JoinConference method is called in your application.
The AutomationBeginStartConversation(String, Int32, AsyncCallback, Object) method is called in your application.
The Automation.BeginMeetNow method is called in your application.
All of these actions raise the ConversationManager.ConversationAdded event. It is important to be able to distinguish the origin of the conversation starting action to determine the action your event callback method will take. You must infer the originating action by examining the two properties of the event state. These event state properties are:
The ConversationManagerEventArgs.Conversation property, which returns the new Conversation object.
The Modality.State property, which is read from the InstantMessageModality object that you obtain from the new Conversation.
If the originating action is a Lync 2013 API method call, you should have cached the Microsoft.Lync.Model.Conversation.Conversation object obtained synchronously from the method call. Compare the cached Conversation object to the ConversationManagerEventArgs.Conversation property. If the comparison shows that these values reference the same Conversation object, the event is the result of a method call in your application.
If the originating action is not a Lync 2013 API method call, then a comparison to any cached Conversation object results in inequality. In this case, you must determine whether the new conversation is the result of an invitation from another user or started locally by using a Lync Control or the client itself. The state of the new conversation IM modality is always ModalityState.Notified when the new conversation is the result of an invitation.
If you are interested in reacting to any of these kinds of conversation-starting events, you must register an event handler for the event. If the event is raised because the user started a conversation using a Lync Control or the client, you can ignore the new conversation because it is being hosted in a conversation window by the Lync 2013 client itself. An exception to this rule is the scenario where you want to dock all conversation windows in container controls within your application.
The conversation invitation action and all Lync 2013 API method call actions raise the ConversationManager.ConversationAdded event and must be handled by your application.