private void HangUpVideoCallInstance(string userId) { Contact contact = this.ContactManager.GetContactByUri(userId); if (contact == null) { return; } ConversationInfo info = this.ConversationInfos.Values.Where(convInfo => convInfo.Contact == contact).FirstOrDefault(); if (info != null) { var conversation = info.Conversation; this.ConversationInfos.Remove(conversation); info.StopVideo(); if (info.ConversationEnded != null) { info.ConversationEnded(null); } info.Dispose(); //if the conversation is active, will end it if (conversation.State != ConversationState.Terminated) { //ends the conversation which will disconnect all modalities try { conversation.End(); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (Utilities.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } } } }
/// <summary> /// Called when a conversation is removed. /// /// Will dispose the window associated with the removed conversation. /// </summary> void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e) { //posts the execution into the UI thread UiThreadControl.BeginInvoke(new MethodInvoker(delegate() { //checks if a conversation window was created, and dispose it if (this.ConversationInfos.ContainsKey(e.Conversation)) { //gets the existing conversation window ConversationInfo info = ConversationInfos[e.Conversation]; //remove the conversation from the dictionary this.ConversationInfos.Remove(e.Conversation); if (info.ConversationEnded != null) { info.ConversationEnded(null); } //cleanup info.Dispose(); } })); }