Last active
August 9, 2016 07:37
-
-
Save adoprog/155f55467be5624266068375514d19d1 to your computer and use it in GitHub Desktop.
Lync - subscribe to IM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static LyncClient client; | |
// Your custom class that handles conversation events | |
private static LyncConversationManager conversation; | |
static void Main(string[] args) | |
{ | |
client = LyncClient.GetClient(); | |
conversation = new LyncConversationManager(brain, client); | |
conversation.StartListening(); | |
Console.ReadKey(); | |
} | |
... | |
public void StartListening() | |
{ | |
lyncClient.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; | |
} | |
private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e) | |
{ | |
e.Conversation.ParticipantAdded += Conversation_ParticipantAdded; | |
foreach (var key in e.Conversation.Modalities.Keys) | |
{ | |
Modality val = e.Conversation.Modalities[key]; | |
if (val != null) | |
{ | |
val.Accept(); | |
} | |
} | |
} | |
... | |
private void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) | |
{ | |
if (e.Participant.IsSelf == false) | |
{ | |
var imModality = (InstantMessageModality) e.Participant.Modalities[ModalityTypes.InstantMessage]; | |
imModality.InstantMessageReceived += ImModality_InstantMessageReceived; | |
} | |
} | |
private void ImModality_InstantMessageReceived(object sender, MessageSentEventArgs e) | |
{ | |
InstantMessageModality im = (InstantMessageModality)sender; | |
if (!im.Participant.IsSelf) | |
{ | |
// Here goes the code that will forward and respond to the messages | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment