/// <summary>保存登录信息</summary> /// <param name="user"></param> /// <param name="session"></param> public static void SaveLogin(this IManageUser user, INetSession session) { user.Logins++; user.LastLogin = DateTime.Now; if (session != null) { user.LastLoginIP = session.Remote?.EndPoint?.Address + ""; // 销毁时 session.OnDisposed += (s, e) => { user.Online = false; user.Save(); }; } user.Online = true; user.Save(); }
/// <summary>保存注册信息</summary> /// <param name="user"></param> /// <param name="session"></param> public static void SaveRegister(this IManageUser user, INetSession session) { //user.Registers++; user.RegisterTime = DateTime.Now; //user.RegisterIP = ns.Remote.EndPoint.Address + ""; if (session != null) { user.RegisterIP = session.Remote?.Address + ""; // 销毁时 session.OnDisposed += (s, e) => { user.Online = false; user.Save(); }; } user.Online = true; user.Save(); }