Search code examples
c#lynclync-2013skype-for-business

How to detect Type/Modality of Lync Conversation?


I need to check whether the conversation is an audio call or a chat. The check needs to happen at the moment the ConversationManager_ConversationAdded Event is triggered.

        private void InitialisiereLyncClient()
        {
            //(Running Lync instance)
            m_LyncClient = LyncClient.GetClient();
            ConversationManager m_ConversationManager = m_LyncClient.ConversationManager;


            m_ConversationManager.ConversationAdded += M_ConversationManager_ConversationAdded;
            m_ConversationManager.ConversationRemoved += M_ConversationManager_ConversationRemoved; 
        }

Here i would like to check what kind of Conversation it is to handle future actions.

        //Eigenschaften der Conversation
        IDictionary<ConversationProperty, object> m_properties = e.Conversation.Properties;

        //Informationen der Person, die das Event ausgelöst hat
        Contact m_caller = e.Conversation.Properties[ConversationProperty.Inviter] as Contact;

Question: How can i distinguish whether the conversation is an Audio/Video call or a Chat conversation?


Solution

  • I have found a solution that works.

            bool hasAVModality = e.Conversation.Modalities.ContainsKey(ModalityTypes.AudioVideo);
            if (hasAVModality)
            {
                //State of AV modality
                var state = e.Conversation.Modalities[ModalityTypes.AudioVideo].State;
                //Notified = Incoming
                if (state == ModalityState.Notified)
                {
                    //Do Something with the call
                }
            }