Ejemplo n.º 1
0
        public override UserBase GetUser(string nickname)
        {
            string id = nickname.ToLower();

            if (!UsersById.ContainsKey(id))
            {
                return(null);
            }

            UserBase user = UsersById[id];

            if (user.Level < Authorizations.Unregistered)
            {
                return(null);
            }
            else
            {
                return(user);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns all users in the room sorted by name.
        /// This will also update the status of the unseen users to offline.
        /// </summary>
        public List <ChatUser> UpdateStatusesAndGetUserList()
        {
            lock (this.usersInRoomLock)
            {
                var lastSeenLimit = DateTime.UtcNow - InactivityTolerance;
                var inactiveUsers = this.UsersById.Values.Where(u => u.LastActiveOn < lastSeenLimit).ToArray();

                // inactive users will be removed, but they could just be made offline
                foreach (var inactiveUser in inactiveUsers)
                {
                    UsersById.Remove(inactiveUser.Id);
                }

                if (inactiveUsers.Any())
                {
                    this.lastTimeRoomChanged = DateTime.UtcNow.Ticks;
                }

                return(this.UsersById.Values.OrderBy(u => u.Name).ToList());
            }
        }