Пример #1
0
        /// <summary>
        ///     取得一个人的在线状态
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        bool IUserOnline.IsOnLine(decimal uid)
        {
            if (OnlineUser.Count() == 0)
            {
                return(false);
            }

            OnlineUserInfo online = OnlineUser.FirstOrDefault(x => x.Uid == uid);

            if (online == null)
            {
                return(false);
            }

            //if (online.Uid != uid) return false;

            //假设最后一次是活动在20分钟内
            if (online.LASTActive < DateTime.Now.AddMinutes(-20))
            {
                ((IUserOnline)this).RemoveUser(uid);
                return(false);
            }

            return(true);
        }
Пример #2
0
 /// <summary>
 ///     加入一个用户进入在线列表
 /// </summary>
 /// <param name="userinfo"></param>
 void IUserOnline.AddUser(OnlineUserInfo userinfo)
 {
     if (!(_onlineUser.Where(p => p.Uid == userinfo.Uid).Count() > 0))
     {
         _onlineUser.Add(userinfo);
         SortUser();
     }
 }
Пример #3
0
 /// <summary>
 ///     加入一个用户进入在线列表
 /// </summary>
 /// <param name="userinfo"></param>
 void IUserOnline.AddUser(OnlineUserInfo userinfo)
 {
     if (!(_onlineUser.Where(p => p.Uid == userinfo.Uid).Count() > 0))
     {
         _onlineUser.Add(userinfo);
         SortUser();
     }
 }
Пример #4
0
        /// <summary>
        ///     更新在线状态
        /// </summary>
        /// <param name="uid"></param>
        internal void FreshUser(decimal uid)
        {
            OnlineUserInfo online = OnlineUser.FirstOrDefault(x => x.Uid == uid);

            if (online == null)
            {
                ((IUserOnline)this).AddUser(new OnlineUserInfo {
                    Uid = uid, LASTActive = DateTime.Now
                });
                return;
            }
            ;

            online.LASTActive = DateTime.Now;
        }
Пример #5
0
        /// <summary>
        ///     移除
        /// </summary>
        /// <param name="uid"></param>
        void IUserOnline.RemoveUser(decimal uid)
        {
            if (OnlineUser.Count() == 0)
            {
                return;
            }
            if (OnlineUser == null)
            {
                return;
            }

            OnlineUserInfo user = OnlineUser.FirstOrDefault(x => x.Uid == uid);

            if (user != null)
            {
                _onlineUser.Remove(user);
            }
        }