网络优化和bug修复
This commit is contained in:
parent
a0fedc60ad
commit
3c76dfe2ef
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user