JLChen
2020-11-25 52e05a5fb6e07afbb14960fc3cbb8a8971e19eb2
HDL_ON/DAL/Server/IMessageCommon.cs
@@ -30,6 +30,12 @@
                return m_Current;
            }
        }
        /// <summary>
        /// 是否在获取token
        /// </summary>
        public bool isGetingToken;
        /// <summary>
        /// 无视错误(访问云端时,此操作将不会弹出错误)
        /// </summary>
@@ -69,7 +75,7 @@
            //验证码发送频繁,请稍后再试!
            stateCodeDic["15"] = HDL_ON.StringId.VerificationCodeSentFrequently;
            //会话超时,请更新token
            stateCodeDic["10001"] = HDL_ON.StringId.NotLogin;
            stateCodeDic[StateCode.TOKEN_EXPIRED] = HDL_ON.StringId.NotLogin;
            ////登录失败,账号或者密码错误
            stateCodeDic["10008"] = HDL_ON.StringId.LoginFailed_AccountOrPasswordError;
            //账号不存在
@@ -231,6 +237,13 @@
        {
            try
            {
                //如果是token过期则刷新token
                if (statuCode == StateCode.TOKEN_EXPIRED)
                {
                    StartRefreshToken();
                }
                else
                {
                string mes = GetMsgByRequestName(statuCode);
                if (mes == null) return;
                if (!string.IsNullOrEmpty(tipStr))
@@ -239,7 +252,8 @@
                }
                if (isTipStyle)
                {
                    Application.RunOnMainThread(() => {
                        Application.RunOnMainThread(() =>
                        {
                        var tip = new Tip()
                        {
                            Text = mes,
@@ -251,12 +265,44 @@
                }
                else
                {
                    Application.RunOnMainThread(() => {
                        Application.RunOnMainThread(() =>
                        {
                        new Alert("", mes, Language.StringByID(HDL_ON.StringId.Close)).Show();
                    });
                }
            }
            }
            catch { }
        }
        /// <summary>
        /// StartRefreshToken
        /// </summary>
        void StartRefreshToken()
        {
            if (isGetingToken) return;
            new System.Threading.Thread(() =>
            {
                isGetingToken = true;
                try
                {
                    var success = new HttpServerRequest().RefreshToken();
                    if (success) {
                        Utlis.WriteLine("RefreshToken success");
                    }
                }
                catch
                {
                }
                finally
                {
                    isGetingToken = false;
                }
            })
            { IsBackground = true }.Start();
        }
    }
@@ -274,5 +320,10 @@
        /// </summary>
        public const string ACCOUNT_NOT_EXIST = "10010";
        /// <summary>
        /// 会话超时,请更新token
        /// </summary>
        public const string TOKEN_EXPIRED = "10001";
    }
}