/// <summary> /// Initializes a new instance of the <see cref="Account"/> class. /// </summary> public Account(LogicLong accountId, string passToken) : this() { this.Id = accountId; this.PassToken = passToken; this.AccountCreatedDate = LogicTimeUtil.GetTimestampMS(); }
/// <summary> /// Handle the login of client. /// </summary> internal void StartSession(Account account, string ipAddress, string deviceModel, byte[] sessionId, int proxyId) { if (account.Session != null) { NetAccountSessionManager.TryRemove(account.Session.SessionId); account.Session.SendMessage(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, new UnbindServerMessage()); account.Session.Destruct(); account.SetSession(null); } NetAccountSession session = NetAccountSessionManager.Create(account, sessionId); account.SetSession(session); account.SessionStarted(LogicTimeUtil.GetTimestamp(), ipAddress, deviceModel); session.SetServiceNodeId(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, proxyId); LoginClientOkMessage loginClientOkMessage = new LoginClientOkMessage(); loginClientOkMessage.SetAccountId(account.Id); loginClientOkMessage.SetHomeId(account.Id); loginClientOkMessage.SetPassToken(account.PassToken); loginClientOkMessage.SetAccountCreatedDate(account.AccountCreatedDate); loginClientOkMessage.SetSessionCount(account.TotalSessions); loginClientOkMessage.SetPlayTimeSeconds(account.PlayTimeSecs); session.SendMessage(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, loginClientOkMessage); }
/// <summary> /// Gets the remaining ban time. /// </summary> internal int GetRemainingBanTime() { if (this.CurrentBan != null) { if (this.CurrentBan.EndBanTime != -1) { return(LogicMath.Max(LogicTimeUtil.GetTimestamp() - this.CurrentBan.EndBanTime, 0)); } return(-1); } return(0); }
/// <summary> /// Called when the session is ended. /// </summary> internal void EndSession() { if (this.LastSessions.Count != 0) { AccountSession session = this.LastSessions[this.LastSessions.Count - 1]; if (session.EndTime == 0) { session.SetEndTime(LogicTimeUtil.GetTimestamp()); if (session.EndTime > session.StartTime) { this.PlayTimeSecs += session.EndTime - session.StartTime; } } } }
/// <summary> /// Gets if this <see cref="Account"/> instance is banned. /// </summary> internal bool IsBanned() { if (this.CurrentBan != null) { if (this.CurrentBan.EndBanTime != -1) { if (LogicTimeUtil.GetTimestamp() > this.CurrentBan.EndBanTime) { this.CurrentBan = null; return(false); } } return(true); } return(false); }
/// <summary> /// Initializes this instance. /// </summary> internal static void Initialize() { AccountManager._accountCounters = new int[DatabaseManager.GetDatabaseCount(0)]; AccountManager._random = new LogicRandom(LogicTimeUtil.GetTimestamp()); AccountManager._accounts = new Dictionary <long, Account>(); }