/// <summary> /// Attaches a new message into the specified group id, if the group is not found then the message is added to the default group. /// </summary> /// <param name="incomingMessage"></param> /// <returns></returns> public ChatGroup AttachMessage(ChatMessage incomingMessage) { ChatGroup referredGroup = null; if (incomingMessage == null) { return(this.defaultChatGroup); } if (this.chatGroups.TryGetValue(incomingMessage.GroupId, out referredGroup)) { referredGroup.AddMessage(incomingMessage); return(referredGroup); } else { this.defaultChatGroup.AddMessage(incomingMessage); } return(this.defaultChatGroup); }