Lync Incoming Call Detection

I am trying to detect an incoming call in a Lync client. This is done by subscribing to the ConversationManager.ConversationAdded event in the Lync client, as described in this post.

However, using this method, I cannot detect incoming calls if the conversation window with the caller is already open before the caller calls. For example, if I talk with a friend and therefore have open conversation windows, and this friend decides to call me, the ConversationAdded event does not fire.

How can I detect incoming calls when I already have an active conversation with the caller?

Thanks Niklas

+6
source share
2 answers

You must subscribe to the ModalityStateChanged talk event. Modalities [ModalityTypes.AudioVideo], this will give you events when the AV modality is created or the state changes.

+5
source

You need to track the modality states in the conversation. The two available modalities are IM and AV, so you will need to monitor the state changes on them, for example:

void ConversationManager_ConversationAdded(object sender, Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs e) { e.Conversation.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += IMModalityStateChanged; e.Conversation.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += AVModalityStateChanged; } void IMModalityStateChanged(object sender, ModalityStateChangedEventArgs e) { if (e.NewState == ModalityState.Connected) MessageBox.Show("IM Modality Connected"); } void AVModalityStateChanged(object sender, ModalityStateChangedEventArgs e) { if (e.NewState == ModalityState.Connected) MessageBox.Show("AV Modality Connected"); } 

This example uses the ConversationAdded event to connect event handlers to modality changes, so this will only work for conversations that are fired while your application is running. To do the same for conversations that are already active prior to launching your application, you can add this code to your application launcher:

 foreach (var conv in _lync.ConversationManager.Conversations) { conv.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += new EventHandler<ModalityStateChangedEventArgs>(IMModalityStateChanged); conv.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += new EventHandler<ModalityStateChangedEventArgs>(AVModalityStateChanged); } 
+8
source

Source: https://habr.com/ru/post/908018/


All Articles