网络模块优化和bug提交
This commit is contained in:
parent
a0fedc60ad
commit
2b0d5b7596
@ -214,6 +214,7 @@ BIReport.NETWORK_OPT_TYPE = {
|
|||||||
RECONNECT = "reconnect",
|
RECONNECT = "reconnect",
|
||||||
ERROR_CODE = "errorCode",
|
ERROR_CODE = "errorCode",
|
||||||
PD_DECODE_FAILED = "pdDecodeFailed",
|
PD_DECODE_FAILED = "pdDecodeFailed",
|
||||||
|
AUTH_FAILED = "authFailed",
|
||||||
}
|
}
|
||||||
|
|
||||||
BIReport.DIALY_CHALLENGE_OPT_TYPE = {
|
BIReport.DIALY_CHALLENGE_OPT_TYPE = {
|
||||||
@ -1114,4 +1115,15 @@ function BIReport:postRateOpen()
|
|||||||
self:report(EVENT_NAME_MISCELLANEOUS_OPT, args)
|
self:report(EVENT_NAME_MISCELLANEOUS_OPT, args)
|
||||||
end
|
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
|
||||||
|
|
||||||
return BIReport
|
return BIReport
|
||||||
@ -221,6 +221,13 @@ function NetManager:connect(domain, port, callback, socketName)
|
|||||||
if ok and pbData then
|
if ok and pbData then
|
||||||
pbData.status = not pbData.err_code and 0 or ProtoMsgDispatch:getErrCodeEnum(pbData.err_code)
|
pbData.status = not pbData.err_code and 0 or ProtoMsgDispatch:getErrCodeEnum(pbData.err_code)
|
||||||
if pbData.status ~= 0 then
|
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
|
if self.authFailToLogin then
|
||||||
self:closeAll()
|
self:closeAll()
|
||||||
self:clearTagAuthFailToLogin()
|
self:clearTagAuthFailToLogin()
|
||||||
@ -251,22 +258,35 @@ function NetManager:connect(domain, port, callback, socketName)
|
|||||||
ModuleManager.LoginManager:initSocket()
|
ModuleManager.LoginManager:initSocket()
|
||||||
end, loginType)
|
end, loginType)
|
||||||
else
|
else
|
||||||
LocalData:setLastLoginInfo()
|
if not self.autoReAuth then
|
||||||
ModuleManager.LoginManager:saveAuthArgs(false)
|
self.autoReAuth = true
|
||||||
local params = {
|
self.autoReAuthSid = self:performWithDelayGlobal(function()
|
||||||
content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_RELOGIN),
|
|
||||||
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
|
||||||
noShowClose = true,
|
|
||||||
okFunc = function()
|
|
||||||
ModuleManager.LoginManager:initSocket()
|
ModuleManager.LoginManager:initSocket()
|
||||||
end,
|
end, 0.5)
|
||||||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
|
else
|
||||||
top = true,
|
LocalData:setLastLoginInfo()
|
||||||
}
|
ModuleManager.LoginManager:saveAuthArgs(false)
|
||||||
GFunc.showMessageBox(params)
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
if self.autoReAuthSid then
|
||||||
|
SchedulerManager:unscheduleGlobal(self.autoReAuthSid)
|
||||||
|
self.autoReAuthSid = nil
|
||||||
|
end
|
||||||
|
self.autoReAuth = false
|
||||||
self:clearTagAuthFailToLogin()
|
self:clearTagAuthFailToLogin()
|
||||||
ModuleManager.LoginManager:saveAuthArgs(true)
|
ModuleManager.LoginManager:saveAuthArgs(true)
|
||||||
UIManager:hideWaitNet(true)
|
UIManager:hideWaitNet(true)
|
||||||
@ -568,6 +588,10 @@ function NetManager:disconnectAndReconnect()
|
|||||||
if self.reconnectMainId then
|
if self.reconnectMainId then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if self.mainReconnectWaitTime > MAX_MAIN_WAIT_TIME then
|
||||||
|
self.mainReconnectWaitTime = MAX_MAIN_WAIT_TIME
|
||||||
|
end
|
||||||
|
|
||||||
self.reconnectMainId = self:performWithDelayGlobal(function ()
|
self.reconnectMainId = self:performWithDelayGlobal(function ()
|
||||||
self.reconnectMainId = nil
|
self.reconnectMainId = nil
|
||||||
self:silentReconnectMain()
|
self:silentReconnectMain()
|
||||||
@ -639,17 +663,16 @@ function NetManager:disconnect(socketName)
|
|||||||
end
|
end
|
||||||
else -- 否则就悄咪咪的重连
|
else -- 否则就悄咪咪的重连
|
||||||
if self.mainReconnectWaitTime > MAX_MAIN_WAIT_TIME then
|
if self.mainReconnectWaitTime > MAX_MAIN_WAIT_TIME then
|
||||||
self:showReconnectMain()
|
self.mainReconnectWaitTime = MAX_MAIN_WAIT_TIME
|
||||||
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
|
|
||||||
end
|
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
|
end
|
||||||
else -- 从来没有连上过
|
else -- 从来没有连上过
|
||||||
self:closeAll()
|
self:closeAll()
|
||||||
@ -840,7 +863,6 @@ end
|
|||||||
|
|
||||||
function NetManager:onError(socketName, errorType, errorMsg)
|
function NetManager:onError(socketName, errorType, errorMsg)
|
||||||
self.isSending = false
|
self.isSending = false
|
||||||
errorType = NetErrorCode.ServerRefuseReconnect
|
|
||||||
if socketName == NetManager.MAIN_SOCKET_NAME then
|
if socketName == NetManager.MAIN_SOCKET_NAME then
|
||||||
Logger.logHighlight("game net error:errorType = %d, errorMsg = %s", errorType, errorMsg)
|
Logger.logHighlight("game net error:errorType = %d, errorMsg = %s", errorType, errorMsg)
|
||||||
if errorType == NetErrorCode.ConnectFailed or
|
if errorType == NetErrorCode.ConnectFailed or
|
||||||
@ -961,6 +983,11 @@ function NetManager:closeAndClear()
|
|||||||
self.joinChatId = nil
|
self.joinChatId = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.autoReAuthSid then
|
||||||
|
SchedulerManager:unscheduleGlobal(self.autoReAuthSid)
|
||||||
|
self.autoReAuthSid = nil
|
||||||
|
end
|
||||||
|
|
||||||
self.isSending = false
|
self.isSending = false
|
||||||
self.sendQueue = {}
|
self.sendQueue = {}
|
||||||
self.tillBeforeOverCount = 0
|
self.tillBeforeOverCount = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user