Example #1
0
        public NewChatRoom GetRoom(NewUser otherUser, bool group = false)
        {
            if (group)
            {
                var ret = Rooms.SingleOrDefault(x => x.IsGroupChat && x.GroupUser.Equals(otherUser));
                if (ret == null)
                {
                    ret = new NewChatRoom(NextRid, _client, otherUser);
                    Rooms.Add(ret);
                    if (OnCreateRoom != null)
                    {
                        OnCreateRoom(this, ret);
                    }
                }
                return(ret);
            }
            else
            {
                var ret = Rooms.SingleOrDefault(x => x.Users.Contains(otherUser) && !x.IsGroupChat);
                if (ret == null)
                {
                    ret = new NewChatRoom(NextRid, _client, otherUser);
                    Rooms.Add(ret);
                    if (OnCreateRoom != null)
                    {
                        OnCreateRoom(this, ret);
                    }
                }

                return(ret);
            }
        }
Example #2
0
 public void RemoveRoom(NewChatRoom room)
 {
     Rooms.Remove(room);
 }