/// <summary> /// Creates a chat of type with person /// </summary> static public void InitiateChat(Person person, ChatType type) { Logger.Debug("ChatWindowManager.InitiateChat with {0}", person.DisplayName); if (person.ProviderUser == null) { throw new ApplicationException("Person contained a null ProviderUser"); } if (ChatWindowManager.ChatWindowExists(person.ProviderUser.ID) == true) { ChatWindow cw = ChatWindowManager.Instance.chatWindows[person.ProviderUser.ID]; cw.UpdateChatType(type); cw.Present(); } else { // Create a new ChatWindow ChatWindow cw = new ChatWindow(person, person.ProviderUser, type); ChatWindowManager.Instance.chatWindows[person.ProviderUser.ID] = cw; cw.DeleteEvent += ChatWindowManager.Instance.OnChatWindowDeleted; Logger.Debug("About to present the window to chat with: {0}", person.DisplayName); cw.Present(); } }
/// <summary> /// OnNewIncomingConversation /// Handles new conversations initiated by a peer /// </summary> private void OnNewIncomingConversation(Conversation conversation, ChatType chatType) { Logger.Debug("NotificationManager.OnNewIncomingConversation was called"); if (conversation.PeerUser == null) { Logger.Error("NewIncomingConversation event had a conversation with null PeerUser"); return; } // If we have a ChatWindow for this conversation, don't do anything... the ChatWindow // will handle the change if (ChatWindowManager.ChatWindowExists(conversation.PeerUser.ID)) { return; } if (chatType == ChatType.Text) { NotifyOfTextMessage(conversation); } else if (chatType == ChatType.Audio) { NotifyOfAudioRequest(conversation); } else if (chatType == ChatType.Video) { NotifyOfVideoRequest(conversation); } conversation.MessageReceived += OnTextAdditionalMessageReceived; conversation.MediaChannelOpened += OnMediaChannelOpened; conversation.MediaChannelClosed += OnMediaChannelClosed; conversation.TextChannelOpened += OnTextChannelOpened; }
/// <summary> /// OnNewIncomingConversation /// Handles new conversations initiated by a peer /// </summary> static internal void HandleAcceptedConversation(Conversation conversation, ChatType chatType) { Logger.Debug("ChatWindowManager.NewAcceptedConversation was called"); if (conversation.PeerUser == null) { Logger.Error("NewIncomingConversation event had a conversation with null PeerUser"); return; } // If we have a ChatWindow for this conversation, don't do anything... the ChatWindow // will handle the change if (ChatWindowManager.ChatWindowExists(conversation.PeerUser.ID)) { return; } ChatWindowManager cwm = ChatWindowManager.Instance; Logger.Debug("**************Creating chat window"); ChatWindow cw = new ChatWindow(conversation, chatType); Logger.Debug("**************Creating chat window 2"); cwm.chatWindows[conversation.PeerUser.ID] = cw; cw.DeleteEvent += cwm.OnChatWindowDeleted; cw.ShowAll(); }