/// <summary> /// 添加一个登录账户.让他保持登录状态. /// </summary> /// <param name="ls"></param> private void AddLoginState(LoginState ls) { lock (_LoginLock) { if (_LoginList.ContainsKey(ls.Name)) { _LoginList[ls.Name].UpdateTime(); } else { _LoginList.Add(ls.Name, ls); } } }
/// <summary> /// 用户登录. /// </summary> /// <param name="user"></param> /// <returns></returns> public LoginResult Login(User user) { lock (_UserListLock) { int index = _UserList.IndexOf(user); if (index > -1) { user = _UserList[index]; LoginState ls = new LoginState(user.Name); if (user.Type == User.UserType.Admin) { ls.IsAdmin = true; } AddLoginState(ls); return(LoginResult.Succeed); } } return(LoginResult.PassWordError); }