From 3c76dfe2efa9f47d0db61c50dfaae68e3c1ed00b Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Thu, 13 Jul 2023 10:35:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E4=BC=98=E5=8C=96=E5=92=8Cbu?= =?UTF-8?q?g=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/bi_report.lua | 12 +++++++ lua/app/net/net_manager.lua | 68 ++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index 744cb598..f1cff365 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -214,6 +214,7 @@ BIReport.NETWORK_OPT_TYPE = { RECONNECT = "reconnect", ERROR_CODE = "errorCode", PD_DECODE_FAILED = "pdDecodeFailed", + AUTH_FAILED = "authFailed", } BIReport.DIALY_CHALLENGE_OPT_TYPE = { @@ -1099,6 +1100,17 @@ function BIReport:postPbDecodefailed(pbName, reqData) self:report(EVENT_NAME_NETWORK_OPT, args) end +function BIReport:postPbAuthfailed(pbName, lastLoginInfo, authFailToLogin) + local args = { + event_type = BIReport.NETWORK_OPT_TYPE.AUTH_FAILED, + pb_name = pbName, + ui_name = UIManager:getTopUIIndex(), + lastLoginInfo = lastLoginInfo, + authFailToLogin = authFailToLogin + } + self:report(EVENT_NAME_NETWORK_OPT, args) +end + function BIReport:postRateClose(rateStar) local args = { event_type = BIReport.MISCELLANEOUS_OPT_TYPE.EVALUATE_CLOSE, diff --git a/lua/app/net/net_manager.lua b/lua/app/net/net_manager.lua index 3564803e..173a7079 100644 --- a/lua/app/net/net_manager.lua +++ b/lua/app/net/net_manager.lua @@ -221,6 +221,13 @@ function NetManager:connect(domain, port, callback, socketName) if ok and pbData then pbData.status = not pbData.err_code and 0 or ProtoMsgDispatch:getErrCodeEnum(pbData.err_code) if pbData.status ~= 0 then + local lastLoginInfo = LocalData:getLastLoginInfo() + BIReport:postPbAuthfailed(ProtoMsgType.FromMsgEnum.AuthReq, lastLoginInfo, self.authFailToLogin) + if self.autoReAuthSid then + SchedulerManager:unscheduleGlobal(self.autoReAuthSid) + self.autoReAuthSid = nil + end + if self.authFailToLogin then self:closeAll() self:clearTagAuthFailToLogin() @@ -251,22 +258,35 @@ function NetManager:connect(domain, port, callback, socketName) ModuleManager.LoginManager:initSocket() end, loginType) else - LocalData:setLastLoginInfo() - ModuleManager.LoginManager:saveAuthArgs(false) - local params = { - content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_RELOGIN), - okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), - noShowClose = true, - okFunc = function() + if not self.autoReAuth then + self.autoReAuth = true + self.autoReAuthSid = self:performWithDelayGlobal(function() ModuleManager.LoginManager:initSocket() - end, - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK, - top = true, - } - GFunc.showMessageBox(params) + end, 0.5) + else + LocalData:setLastLoginInfo() + ModuleManager.LoginManager:saveAuthArgs(false) + local params = { + content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_RELOGIN), + okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), + noShowClose = true, + okFunc = function() + self.autoReAuth = false + ModuleManager.LoginManager:initSocket() + end, + boxType = GConst.MESSAGE_BOX_TYPE.MB_OK, + top = true, + } + GFunc.showMessageBox(params) + end end end else + if self.autoReAuthSid then + SchedulerManager:unscheduleGlobal(self.autoReAuthSid) + self.autoReAuthSid = nil + end + self.autoReAuth = false self:clearTagAuthFailToLogin() ModuleManager.LoginManager:saveAuthArgs(true) UIManager:hideWaitNet(true) @@ -568,6 +588,10 @@ function NetManager:disconnectAndReconnect() if self.reconnectMainId then return end + if self.mainReconnectWaitTime > MAX_MAIN_WAIT_TIME then + self.mainReconnectWaitTime = MAX_MAIN_WAIT_TIME + end + self.reconnectMainId = self:performWithDelayGlobal(function () self.reconnectMainId = nil self:silentReconnectMain() @@ -639,17 +663,16 @@ function NetManager:disconnect(socketName) end else -- 否则就悄咪咪的重连 if self.mainReconnectWaitTime > MAX_MAIN_WAIT_TIME then - self:showReconnectMain() - else - if self.reconnectMainId then - return - end - self.reconnectMainId = self:performWithDelayGlobal(function () - self.reconnectMainId = nil - self:silentReconnectMain() - end, self.mainReconnectWaitTime) - self.mainReconnectWaitTime = self.mainReconnectWaitTime + 1 + self.mainReconnectWaitTime = MAX_MAIN_WAIT_TIME end + if self.reconnectMainId then + return + end + self.reconnectMainId = self:performWithDelayGlobal(function () + self.reconnectMainId = nil + self:silentReconnectMain() + end, self.mainReconnectWaitTime) + self.mainReconnectWaitTime = self.mainReconnectWaitTime + 1 end else -- 从来没有连上过 self:closeAll() @@ -840,7 +863,6 @@ end function NetManager:onError(socketName, errorType, errorMsg) self.isSending = false - errorType = NetErrorCode.ServerRefuseReconnect if socketName == NetManager.MAIN_SOCKET_NAME then Logger.logHighlight("game net error:errorType = %d, errorMsg = %s", errorType, errorMsg) if errorType == NetErrorCode.ConnectFailed or