Пример #1
0
        public OperResultObject Login(string clientIP, string userLoginName, string password)
        {
            OperResultObject resultObj = new OperResultObject();

            string     token  = "";
            PlayerInfo player = null;

            try
            {
                player = PlayerController.Instance.GetPlayerInfoByUserLoginName(userLoginName);
                if (player == null)
                {
                    resultObj.OperResultCode = OperResult.RESULTCODE_USERNAME_PASSWORD_ERROR;
                    return(resultObj);
                }
                token = WebClientManager.GetToken(player.SimpleInfo.UserName);
                if (!string.IsNullOrEmpty(token))
                {
                    WebClientManager.RemoveClient(token);
                }

                if (password != player.SimpleInfo.Password)
                {
                    resultObj.OperResultCode = OperResult.RESULTCODE_USERNAME_PASSWORD_ERROR;
                    return(resultObj);
                }

                resultObj = PlayerController.Instance.CheckPlayerIsLocked(player.SimpleInfo.UserID, player.SimpleInfo.UserName);
                if (resultObj.OperResultCode != OperResult.RESULTCODE_TRUE)
                {
                    return(resultObj);
                }

                token = Guid.NewGuid().ToString();
                WebClientManager.AddClient(player.SimpleInfo.UserName, token, clientIP);

                LogHelper.Instance.AddInfoLog("WEB 玩家登录名 [" + userLoginName + "] 登录矿场, IP=" + clientIP);

                resultObj.OperResultCode = OperResult.RESULTCODE_TRUE;
                resultObj.Message        = token;
                return(resultObj);
            }
            catch (Exception exc)
            {
                LogHelper.Instance.AddErrorLog("WEB 玩家登录名 [" + userLoginName + "] 登录矿场失败, IP=" + clientIP, exc);
                resultObj.OperResultCode = OperResult.RESULTCODE_EXCEPTION;
                return(resultObj);
            }
        }
Пример #2
0
        public WebPlayerInfo GetPlayerInfo(string token, string userLoginName, string clientIP)
        {
            try
            {
                string userName = WebClientManager.GetClientUserName(token);
                if (string.IsNullOrEmpty(userName))
                {
                    return(null);
                }

                var playerInfo = PlayerController.Instance.GetPlayerInfoByUserName(userName);
                if (playerInfo.SimpleInfo.UserLoginName != userLoginName)
                {
                    return(null);
                }

                WebPlayerInfo webPlayerInfo = new WebPlayerInfo()
                {
                    Token           = token,
                    UserName        = playerInfo.SimpleInfo.UserName,
                    UserLoginName   = playerInfo.SimpleInfo.UserLoginName,
                    ShoppingCredits = playerInfo.FortuneInfo.ShoppingCreditsEnabled
                };
                if (playerInfo.FortuneInfo.UserRemoteServerValidStopTime != null)
                {
                    DateTime stopTime = playerInfo.FortuneInfo.UserRemoteServerValidStopTime.ToDateTime();
                    if (stopTime >= DateTime.Now)
                    {
                        webPlayerInfo.UserRemoteServerValidStopTime = playerInfo.FortuneInfo.UserRemoteServerValidStopTime;
                    }
                }
                webPlayerInfo.IsLongTermRemoteServiceUser = playerInfo.FortuneInfo.IsLongTermRemoteServiceUser;
                webPlayerInfo.UserRemoteServiceValidTimes = playerInfo.FortuneInfo.UserRemoteServiceValidTimes;

                return(webPlayerInfo);
            }
            catch (Exception exc)
            {
                LogHelper.Instance.AddErrorLog("WEB 玩家登录名 [" + userLoginName + "] 登录矿场失败, IP=" + clientIP, exc);
                return(null);
            }
        }