internal void AddAccountById(string accountId, AccountInfo accountInfo) { m_AccountById.AddOrUpdate(accountId, accountInfo, (g, u) => accountInfo); }
internal void RemoveAccountById(string accountId) { AccountInfo tmpAi = null; m_AccountById.TryRemove(accountId, out tmpAi); }
internal void DoAccountLoginWithoutQueueing(string accountId, string password, string clientInfo, string nodeName) { AccountInfo accountInfo = m_AccountSystem.FindAccountById(accountId); if (accountInfo == null) { //当前accountId不在线 accountInfo = new AccountInfo(); accountInfo.AccountId = accountId; accountInfo.Password = password; accountInfo.ClientInfo = clientInfo; accountInfo.NodeName = nodeName; accountInfo.CurrentState = AccountState.Unloaded; accountInfo.UserGuid = UserServer.Instance.GlobalProcessThread.GenerateUserGuid(); var dsThread = UserServer.Instance.DataCacheThread; if (dsThread.DataStoreAvailable == true) { m_AccountSystem.AddAccountById(accountId, accountInfo); LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "LoginStep_4: Load account from DataStore . AccountId:{0}", accountId); dsThread.DispatchAction(dsThread.DSPLoadAccount, accountId); } else { accountInfo.CurrentState = AccountState.Online; m_AccountSystem.AddAccountById(accountId, accountInfo); LogSys.Log(LOG_TYPE.INFO, "Account login success. Account:{0}", accountId); NodeMessage replyMsg = new NodeMessage(LobbyMessageDefine.AccountLoginResult, accountId); GameFrameworkMessage.AccountLoginResult protoMsg = new GameFrameworkMessage.AccountLoginResult(); protoMsg.m_AccountId = accountId; protoMsg.m_Result = AccountLoginResult.AccountLoginResultEnum.FirstLogin; protoMsg.m_UserGuid = accountInfo.UserGuid; replyMsg.m_ProtoData = protoMsg; NodeMessageDispatcher.SendNodeMessage(nodeName, replyMsg); } } else { //当前账号在线 if (accountInfo.CurrentState == AccountState.Dropped || clientInfo == accountInfo.ClientInfo) { //账号处在离线状态或同一设备重复登录,登录成功 LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "LoginStep_5a: Account is dropped. Login SUCCESS. AccountId:{0}", accountId); accountInfo.AccountId = accountId; accountInfo.Password = password; accountInfo.ClientInfo = clientInfo; accountInfo.NodeName = nodeName; accountInfo.CurrentState = AccountState.Online; NodeMessage replyMsg = new NodeMessage(LobbyMessageDefine.AccountLoginResult, accountId); GameFrameworkMessage.AccountLoginResult protoMsg = new GameFrameworkMessage.AccountLoginResult(); protoMsg.m_AccountId = accountId; if (null != GetUserInfo(accountInfo.UserGuid)) protoMsg.m_Result = AccountLoginResult.AccountLoginResultEnum.Success; else protoMsg.m_Result = AccountLoginResult.AccountLoginResultEnum.FirstLogin; protoMsg.m_UserGuid = accountInfo.UserGuid; replyMsg.m_ProtoData = protoMsg; NodeMessageDispatcher.SendNodeMessage(nodeName, replyMsg); } else { //账号在别的设备上登录,登录失败 LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "LoginStep_5b: Account is online. Login FAILED. AccountId:{0}", accountId); NodeMessage replyMsg = new NodeMessage(LobbyMessageDefine.AccountLoginResult, accountId); GameFrameworkMessage.AccountLoginResult protoMsg = new GameFrameworkMessage.AccountLoginResult(); protoMsg.m_AccountId = accountId; protoMsg.m_Result = AccountLoginResult.AccountLoginResultEnum.AlreadyOnline; replyMsg.m_ProtoData = protoMsg; NodeMessageDispatcher.SendNodeMessage(nodeName, replyMsg); } } }