Conversation CreateConversation(IContact who, bool clientStarted) { Conversation convo; var events = new ConversationEvents(); if (who is User) { convo = new Conversation(client, who as User, events); } else if (who is Group) { convo = new Conversation(client, who as Group, events); } else { throw new ArgumentException("who is not a User or a Group"); } conversations.Add(convo); conversationEventsMap[who.Name] = events; NewConversation.SafeInvoke(this, new NewConversationEventArgs(convo, clientStarted)); return(convo); }
internal Conversation(ChatClient client, IContact who, ConversationEvents events) { this.client = client; this.events = events; Name = who.Name; Contact = who; events.UserAdded += OnUserAdded; events.UserChanged += OnUserChanged; events.UserRemoved += OnUserRemoved; events.UserTyping += OnUserTyping; events.ChatReceived += OnChatReceived; if (Contact is IUser) { participants.Add(new Participant(Contact as IUser)); } else { foreach (var member in (Contact as IGroup).Members) { participants.Add(new Participant(member)); } } }
Conversation CreateConversation(IContact who, bool clientStarted) { Conversation convo; var events = new ConversationEvents(); if (who is User) convo = new Conversation(client, who as User, events); else if (who is Group) convo = new Conversation(client, who as Group, events); else throw new ArgumentException("who is not a User or a Group"); conversations.Add(convo); conversationEventsMap[who.Name] = events; NewConversation.SafeInvoke(this, new NewConversationEventArgs(convo, clientStarted)); return convo; }