Exemple #1
0
        /// <summary>
        ///     Returns the user list in the given room or conversation
        /// </summary>
        /// <param name="roomId"></param>
        /// <param name="conversationId"></param>
        public List <ChatUserInfo> GetUserList(int?roomId, int?conversationId)
        {
            if (roomId.HasValue)
            {
                var usersInRoom = ChatHubCache.GetRoomUsers(roomId.Value);
                var dbUsers     = this.Db.Users.Where(u => usersInRoom.Contains(u.Id)).ToList();
                return(dbUsers.Select(u => this.GetUserInfo(u, ChatUserInfo.StatusType.Online)).ToList());
            }

            throw new NotImplementedException("Conversations are not supported yet");
        }
Exemple #2
0
 private ChatRoomInfo GetChatRoomInfo(ChatRoom chatRoom)
 {
     if (chatRoom == null)
     {
         throw new ArgumentNullException("chatRoom");
     }
     return(new ChatRoomInfo
     {
         Id = chatRoom.Id,
         Name = chatRoom.Name,
         UsersOnline = ChatHubCache.GetRoomUsers(chatRoom.Id).Count()
     });
 }