Merge branch 'dev' of git.juzugame.com:b6-client/b6-lua into dev
This commit is contained in:
commit
d3b033ecd7
@ -22,6 +22,7 @@ EventManager.CUSTOM_EVENT = {
|
|||||||
ELIMINATION_OVER = "ELIMINATION_OVER",
|
ELIMINATION_OVER = "ELIMINATION_OVER",
|
||||||
SHOW_ELIMINATION_TUTORAIL = "SHOW_ELIMINATION_TUTORAIL",
|
SHOW_ELIMINATION_TUTORAIL = "SHOW_ELIMINATION_TUTORAIL",
|
||||||
BOARD_FILL_OVER = "BOARD_FILL_OVER",
|
BOARD_FILL_OVER = "BOARD_FILL_OVER",
|
||||||
|
LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS",
|
||||||
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
|
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
|
||||||
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
|
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ local LOCAL_DATA_KEY = {
|
|||||||
IS_NEW_PLAYER = "IS_NEW_PLAYER",
|
IS_NEW_PLAYER = "IS_NEW_PLAYER",
|
||||||
DISTINCT_ID = "DISTINCT_ID",
|
DISTINCT_ID = "DISTINCT_ID",
|
||||||
LAST_LOGIN_TIME = "LAST_LOGIN_TIME",
|
LAST_LOGIN_TIME = "LAST_LOGIN_TIME",
|
||||||
|
GATE = "GATE",
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalData.KEYS = LOCAL_DATA_KEY
|
LocalData.KEYS = LOCAL_DATA_KEY
|
||||||
@ -202,6 +203,44 @@ function LocalData:getIosOrders()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function LocalData:setLastLoginInfo(loginType, id, token)
|
||||||
|
local str = json.encode({
|
||||||
|
type = loginType,
|
||||||
|
id = id,
|
||||||
|
token = token
|
||||||
|
})
|
||||||
|
if not loginType then
|
||||||
|
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_TYPE, "")
|
||||||
|
elseif loginType ~= "token" then
|
||||||
|
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_TYPE, loginType)
|
||||||
|
end
|
||||||
|
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_INFO, str)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LocalData:getLastLoginInfo()
|
||||||
|
local str = self:getString(LOCAL_DATA_KEY.LAST_LOGIN_INFO, "{}")
|
||||||
|
local info = json.decode(str)
|
||||||
|
info.type = info.type or NetManager.LOGIN_TYPE.ANONYMOUS
|
||||||
|
info.id = info.id or DeviceHelper:getDeviceId()
|
||||||
|
info.token = info.token
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
function LocalData:getLastLoginType()
|
||||||
|
local str = self:getString(LOCAL_DATA_KEY.LAST_LOGIN_TYPE, "")
|
||||||
|
if str == "" then
|
||||||
|
str = NetManager.LOGIN_TYPE.ANONYMOUS
|
||||||
|
end
|
||||||
|
if str ~= NetManager.LOGIN_TYPE.ANONYMOUS and
|
||||||
|
str ~= NetManager.LOGIN_TYPE.APPLE and
|
||||||
|
str ~= NetManager.LOGIN_TYPE.GOOGLE and
|
||||||
|
str ~= NetManager.LOGIN_TYPE.FACEBOOK
|
||||||
|
then
|
||||||
|
str = NetManager.LOGIN_TYPE.ANONYMOUS
|
||||||
|
end
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
function LocalData:setLastLoginName(name)
|
function LocalData:setLastLoginName(name)
|
||||||
name = name or ""
|
name = name or ""
|
||||||
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, name)
|
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, name)
|
||||||
@ -211,6 +250,23 @@ function LocalData:getLastLoginName()
|
|||||||
return self:getString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, "")
|
return self:getString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function LocalData:saveSendQueue(sendQueue)
|
||||||
|
local str = json.encode(sendQueue)
|
||||||
|
self:setString(LOCAL_DATA_KEY.SEND_QUEUE, str)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LocalData:saveEmptySendQueue()
|
||||||
|
if self.emptyTableJsonStr == nil then
|
||||||
|
self.emptyTableJsonStr = json.encode({})
|
||||||
|
end
|
||||||
|
self:setString(LOCAL_DATA_KEY.SEND_QUEUE, self.emptyTableJsonStr)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LocalData:getSendQueue()
|
||||||
|
local sendQueue = json.decode(self:getString(LOCAL_DATA_KEY.SEND_QUEUE, "{}"))
|
||||||
|
return sendQueue
|
||||||
|
end
|
||||||
|
|
||||||
function LocalData:setShakeMode(value) -- 0-close 1-open
|
function LocalData:setShakeMode(value) -- 0-close 1-open
|
||||||
self:setInt(self:getString(LOCAL_DATA_KEY.SHAKE_MODE), value)
|
self:setInt(self:getString(LOCAL_DATA_KEY.SHAKE_MODE), value)
|
||||||
end
|
end
|
||||||
|
|||||||
23
lua/app/common/server_push_manager.lua
Normal file
23
lua/app/common/server_push_manager.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
local ServerPushManager = {}
|
||||||
|
|
||||||
|
---- 注册推送监听
|
||||||
|
function ServerPushManager:addServerPushListener(msgName, module, callback)
|
||||||
|
NetManager:registerMsgCallback(msgName, module, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
---- 移除推送监听
|
||||||
|
function ServerPushManager:removeServerPushListener(msgName, module)
|
||||||
|
NetManager:unRegisterMsgCallback(msgName, module)
|
||||||
|
end
|
||||||
|
|
||||||
|
---- 初始化全局推送监听
|
||||||
|
function ServerPushManager:initWhenLogin()
|
||||||
|
self:addServerPushListener(ProtoMsgType.FromMsgEnum.KickOutNtf, UIManager, UIManager.showKickOut)
|
||||||
|
end
|
||||||
|
|
||||||
|
---- 移除全局推送监听
|
||||||
|
function ServerPushManager:removeWhenLoginOut()
|
||||||
|
self:removeServerPushListener(ProtoMsgType.FromMsgEnum.KickOutNtf, UIManager)
|
||||||
|
end
|
||||||
|
|
||||||
|
return ServerPushManager
|
||||||
10
lua/app/common/server_push_manager.lua.meta
Normal file
10
lua/app/common/server_push_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a2863b1c3518d154f9c509e0bc0f65c1
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -73,11 +73,13 @@ function Game:initOther()
|
|||||||
BF.exports.EffectManager = require "app/common/effect_manager"
|
BF.exports.EffectManager = require "app/common/effect_manager"
|
||||||
BF.exports.SpineManager = require "app/common/spine_manager"
|
BF.exports.SpineManager = require "app/common/spine_manager"
|
||||||
BF.exports.WebRequestManager = require "app/common/webrequest_manager"
|
BF.exports.WebRequestManager = require "app/common/webrequest_manager"
|
||||||
|
BF.exports.NetManager = require "app/net/net_manager"
|
||||||
BF.exports.I18N = require "app/common/i18n_manager"
|
BF.exports.I18N = require "app/common/i18n_manager"
|
||||||
BF.exports.CellManager = require "app/common/cell_manager"
|
BF.exports.CellManager = require "app/common/cell_manager"
|
||||||
BF.exports.Time = require "app/common/time"
|
BF.exports.Time = require "app/common/time"
|
||||||
BF.exports.BaseData = require "app/userdata/base_data"
|
BF.exports.BaseData = require "app/userdata/base_data"
|
||||||
BF.exports.BaseObject = require "app/bf/unity/base_object"
|
BF.exports.BaseObject = require "app/bf/unity/base_object"
|
||||||
|
BF.exports.ServerPushManager = require "app/common/server_push_manager"
|
||||||
BF.exports.SafeAreaManager = require "app/common/safe_area_manager"
|
BF.exports.SafeAreaManager = require "app/common/safe_area_manager"
|
||||||
BF.exports.BaseModule = require "app/module/base_module"
|
BF.exports.BaseModule = require "app/module/base_module"
|
||||||
BF.exports.ModuleManager = require "app/common/module_manager"
|
BF.exports.ModuleManager = require "app/common/module_manager"
|
||||||
@ -98,6 +100,7 @@ function Game:initOther()
|
|||||||
DataManager:init()
|
DataManager:init()
|
||||||
DOTweenManager:init()
|
DOTweenManager:init()
|
||||||
ModuleManager:init()
|
ModuleManager:init()
|
||||||
|
NetManager:init()
|
||||||
|
|
||||||
-- 例如EmmyLua等IDE或者插件无法识别BF.exports.xx的全局变量赋值语法,这里专门处理一下
|
-- 例如EmmyLua等IDE或者插件无法识别BF.exports.xx的全局变量赋值语法,这里专门处理一下
|
||||||
self:specialForIdea()
|
self:specialForIdea()
|
||||||
@ -140,11 +143,13 @@ function Game:specialForIdea()
|
|||||||
EffectManager = EffectManager or require "app/common/effect_manager"
|
EffectManager = EffectManager or require "app/common/effect_manager"
|
||||||
SpineManager = SpineManager or require "app/common/spine_manager"
|
SpineManager = SpineManager or require "app/common/spine_manager"
|
||||||
WebRequestManager = WebRequestManager or require "app/common/webrequest_manager"
|
WebRequestManager = WebRequestManager or require "app/common/webrequest_manager"
|
||||||
|
NetManager = NetManager or require "app/net/net_manager"
|
||||||
I18N = I18N or require "app/common/i18n_manager"
|
I18N = I18N or require "app/common/i18n_manager"
|
||||||
CellManager = CellManager or require "app/common/cell_manager"
|
CellManager = CellManager or require "app/common/cell_manager"
|
||||||
Time = Time or require "app/common/time"
|
Time = Time or require "app/common/time"
|
||||||
BaseData = BaseData or require "app/userdata/base_data"
|
BaseData = BaseData or require "app/userdata/base_data"
|
||||||
BaseObject = BaseObject or require "app/bf/unity/base_object"
|
BaseObject = BaseObject or require "app/bf/unity/base_object"
|
||||||
|
ServerPushManager = ServerPushManager or require "app/module/login/server_push_manager"
|
||||||
SafeAreaManager = SafeAreaManager or require "app/common/safe_area_manager"
|
SafeAreaManager = SafeAreaManager or require "app/common/safe_area_manager"
|
||||||
BaseModule = BaseModule or require "app/module/base_module"
|
BaseModule = BaseModule or require "app/module/base_module"
|
||||||
ModuleManager = ModuleManager or require "app/common/module_manager"
|
ModuleManager = ModuleManager or require "app/common/module_manager"
|
||||||
|
|||||||
@ -72,6 +72,19 @@ function BaseModule:removeAllEventListeners()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 阻塞式,等待服务器回复以后再回调callback
|
||||||
|
function BaseModule:sendMessage(msgName, params, responseData, callback, getType, lockGame)
|
||||||
|
if lockGame == nil then
|
||||||
|
lockGame = true
|
||||||
|
end
|
||||||
|
NetManager:send(self, msgName, params, responseData, callback, lockGame, nil, getType)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 阻塞式,等待所有指令完成以后再发送此消息,并且锁界面,等待服务器回复以后再回调callback
|
||||||
|
function BaseModule:sendMessageTillBeforeOver(msgName, params, responseData, callback, getType)
|
||||||
|
NetManager:sendTillBeforeOver(self, msgName, params, responseData, callback, true, nil, getType)
|
||||||
|
end
|
||||||
|
|
||||||
-- 各个模块的manager按各自需求来重写clear即可
|
-- 各个模块的manager按各自需求来重写clear即可
|
||||||
function BaseModule:clear()
|
function BaseModule:clear()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -341,4 +341,12 @@ function BattleManager:getBattleUnitAttribute(hashCode)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleManager:clearOnExitScene()
|
||||||
|
if self.battleController == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:clear()
|
||||||
|
self.returnFunc = nil
|
||||||
|
end
|
||||||
|
|
||||||
return BattleManager
|
return BattleManager
|
||||||
@ -73,4 +73,334 @@ function LoginManager:getClientInfo()
|
|||||||
return clientInfo
|
return clientInfo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function LoginManager:initSocket()
|
||||||
|
local isConnected = NetManager:isConnected(NetManager.MAIN_SOCKET_NAME)
|
||||||
|
if EDITOR_MODE then
|
||||||
|
Logger.logError("LoginMgr:initSocket:%s", isConnected)
|
||||||
|
end
|
||||||
|
if not isConnected then
|
||||||
|
NetManager:init(
|
||||||
|
function()
|
||||||
|
self:connectByChannel(
|
||||||
|
function()
|
||||||
|
if EDITOR_MODE then
|
||||||
|
Logger.logError("主链接链接成功")
|
||||||
|
end
|
||||||
|
self:_login()
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:connectByChannel(callback, socketName)
|
||||||
|
socketName = socketName or NetManager.MAIN_SOCKET_NAME
|
||||||
|
local domain
|
||||||
|
local port
|
||||||
|
if socketName == NetManager.MAIN_SOCKET_NAME then
|
||||||
|
local gate = LocalData:getString(LocalData.KEYS.GATE)
|
||||||
|
local arr = string.split(gate, ":")
|
||||||
|
domain = arr[1]
|
||||||
|
port = arr[2]
|
||||||
|
else
|
||||||
|
domain = NetManager:getChatDomain()
|
||||||
|
port = NetManager:getChatPort()
|
||||||
|
end
|
||||||
|
NetManager:connect(domain, port, function()
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end, socketName)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:goToLoginScene()
|
||||||
|
ModuleManager.BattleManager:clearOnExitScene()
|
||||||
|
NetManager:closeAndClear()
|
||||||
|
UIManager:backToLoginWithoutLogout()
|
||||||
|
DataManager:clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function LoginManager:_login()
|
||||||
|
LocalData:saveEmptySendQueue()
|
||||||
|
|
||||||
|
local skipGuide = nil
|
||||||
|
if EDITOR_MODE then
|
||||||
|
-- skipGuide = LocalData:getSkipTutorial()
|
||||||
|
end
|
||||||
|
local clientInfo = self:getClientInfo()
|
||||||
|
if EDITOR_MODE then
|
||||||
|
print("LoginReq===============================xxxx1")
|
||||||
|
for k, v in pairs(clientInfo) do
|
||||||
|
print(k, " = ", v)
|
||||||
|
end
|
||||||
|
print("LoginReq===============================xxxx2")
|
||||||
|
end
|
||||||
|
local args = {
|
||||||
|
client_info = clientInfo,
|
||||||
|
skip_guide = skipGuide,
|
||||||
|
}
|
||||||
|
self:sendMessage(
|
||||||
|
ProtoMsgType.FromMsgEnum.LoginReq,
|
||||||
|
args,
|
||||||
|
{},
|
||||||
|
self.loginFinish
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:loginFinish(data)
|
||||||
|
if data.status == 0 then
|
||||||
|
UIManager:clearUIPrefabCache() -- 先清理下缓存
|
||||||
|
ConfigManager:preLoadConfig()
|
||||||
|
ServerPushManager:initWhenLogin()
|
||||||
|
DataManager:initWithServerData(data)
|
||||||
|
|
||||||
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS)
|
||||||
|
-- ModuleManager.MailManager:getMailList(true)
|
||||||
|
DataManager:setLoginSuccess(true)
|
||||||
|
BIReport:postGameLoginFinish()
|
||||||
|
|
||||||
|
local info = LocalData:getLastLoginInfo()
|
||||||
|
BIReport:postAccountLoginFinish(info.type)
|
||||||
|
else
|
||||||
|
local info = LocalData:getLastLoginInfo()
|
||||||
|
BIReport:postAccountLoginFailed(info.type, data.err_code)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:saveAuthArgs(name)
|
||||||
|
local args = LocalData:getLastLoginInfo()
|
||||||
|
if name then
|
||||||
|
args.type = NetManager.LOGIN_TYPE.ANONYMOUS
|
||||||
|
args.id = name
|
||||||
|
args.token = nil
|
||||||
|
LocalData:setLastLoginName(name)
|
||||||
|
LocalData:setLastLoginInfo(args.type, args.id, args.token)
|
||||||
|
end
|
||||||
|
|
||||||
|
args.client_info = self:getClientInfo()
|
||||||
|
local sendQueue = LocalData:getSendQueue()
|
||||||
|
args.sync =
|
||||||
|
{
|
||||||
|
pip = GFunc.getArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
if sendQueue and sendQueue[1] then
|
||||||
|
local ProtoMsgDispatch = require "app/proto/proto_msg_dispatch"
|
||||||
|
local pb = require "pb"
|
||||||
|
for _, info in ipairs(sendQueue) do
|
||||||
|
local curParams = info.params
|
||||||
|
local needAd = false
|
||||||
|
if info.msgName == ProtoMsgType.FromMsgEnum.PipedReq then
|
||||||
|
local msgName = ProtoMsgDispatch:getReqMsgNameByMsgId(curParams.msg_id)
|
||||||
|
if msgName then
|
||||||
|
local fullMsgName = ProtoMsgDispatch:getMsgFullNameByMsgName(msgName)
|
||||||
|
if fullMsgName then
|
||||||
|
if curParams.data and type(curParams.data) == "table" then
|
||||||
|
local ok, pbData = pcall(function()
|
||||||
|
return pb.encode(fullMsgName, curParams.data)
|
||||||
|
end)
|
||||||
|
if ok then
|
||||||
|
needAd = true
|
||||||
|
curParams.data = pbData
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if needAd then
|
||||||
|
table.insert(args.sync.pip, curParams)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
NetManager:saveAuthArgs(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function LoginManager:resetServerListStartTime()
|
||||||
|
self.accountLoginSuccess = false
|
||||||
|
self.connectStartTimes = os.clock()
|
||||||
|
self.retryTimes = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:addServerListCallback(callback)
|
||||||
|
self.loginCallback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:removeAllLoginData()
|
||||||
|
self.loginCallback = nil
|
||||||
|
self.versionInfoStr = nil
|
||||||
|
self.versionInfo = nil
|
||||||
|
-- self.connectStartTimes = nil
|
||||||
|
self.retryTimes = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:showServerNotOpenMessage()
|
||||||
|
local params = {
|
||||||
|
content = I18N:getGlobalText(I18N.GlobalConst.SERVER_MAINTAINED),
|
||||||
|
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
|
||||||
|
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
||||||
|
okFunc = function()
|
||||||
|
self:checkServerOpen()
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
GFunc.showMessageBox(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:getIsNeedHotUpdate()
|
||||||
|
local serverVersion = self.versionInfo.version
|
||||||
|
local clientVersion = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion()
|
||||||
|
if serverVersion == nil or serverVersion == "" or clientVersion == nil or clientVersion == "" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return serverVersion ~= clientVersion
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:showNewVersionFoundMessage()
|
||||||
|
local params = {
|
||||||
|
content = I18N:getGlobalText(I18N.GlobalConst.NEW_VERSION_FOUND),
|
||||||
|
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
|
||||||
|
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
||||||
|
okFunc = function()
|
||||||
|
local storeUrl = self.versionInfo.store_url
|
||||||
|
if storeUrl == nil or storeUrl == "" then
|
||||||
|
CS.UnityEngine.Application.Quit()
|
||||||
|
else
|
||||||
|
CS.UnityEngine.Application.OpenURL(storeUrl)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
GFunc.showMessageBox(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:getIsclientLessThanMinVersion()
|
||||||
|
local minVersion = self.versionInfo.min_version
|
||||||
|
local clientVersion = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion()
|
||||||
|
if minVersion == nil or minVersion == "" or clientVersion == nil or clientVersion == "" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if minVersion == clientVersion then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local update, bigVersion = GFunc.compareVersionThan(minVersion, clientVersion, false)
|
||||||
|
|
||||||
|
return bigVersion or false
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:checkServerOpen()
|
||||||
|
local serverOpenTime = tonumber(self.versionInfo.open_time or 0)
|
||||||
|
local clientTime = os.time()*1000
|
||||||
|
if clientTime < serverOpenTime then -- 未开服
|
||||||
|
self:showServerNotOpenMessage()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if EDITOR_MODE or GConst.SKIP_VERSION then
|
||||||
|
CS.BF.BFMain.Instance.GameLaunchMgr.LaunchRequester:SetVersionInfo(self.versionInfoStr)
|
||||||
|
if self.loginCallback and self.versionInfo then
|
||||||
|
self.loginCallback(self.versionInfo.game_urls)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- 需要更新整包
|
||||||
|
if self:getIsclientLessThanMinVersion() then
|
||||||
|
self:showNewVersionFoundMessage()
|
||||||
|
elseif self:getIsNeedHotUpdate() then -- 需要热更新
|
||||||
|
Game:destroyAll()
|
||||||
|
CS.BF.BFMain.Instance.GameLaunchMgr:LaunchForRelogin(self.versionInfoStr)
|
||||||
|
else
|
||||||
|
CS.BF.BFMain.Instance.GameLaunchMgr.LaunchRequester:SetVersionInfo(self.versionInfoStr)
|
||||||
|
if self.loginCallback then
|
||||||
|
self.loginCallback(self.versionInfo.game_urls)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function LoginManager:getServerList(callback)
|
||||||
|
if self.accountLoginSuccess then
|
||||||
|
if self.authSid then
|
||||||
|
self:unscheduleGlobal(self.authSid)
|
||||||
|
self.authSid = nil
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.loginCenterUrl = CS.BF.BFPlatform.GetLoginCenterURL()
|
||||||
|
self.retryTimes = self.retryTimes + 1
|
||||||
|
|
||||||
|
SDKManager:getServerList(function(isSuccess, data)
|
||||||
|
if self.accountLoginSuccess then
|
||||||
|
if self.authSid then
|
||||||
|
self:unscheduleGlobal(self.authSid)
|
||||||
|
self.authSid = nil
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if isSuccess and data and data ~= "" then
|
||||||
|
self.versionInfoStr = data
|
||||||
|
local jsonData = json.decode(data or "")
|
||||||
|
if not jsonData.game_urls[1] then -- 保证服务器列表中必须有一个服务器
|
||||||
|
local params = {
|
||||||
|
content = I18N:getGlobalText(I18N.GlobalConst.GET_SEVER_ERROR),
|
||||||
|
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
||||||
|
noShowClose = true,
|
||||||
|
okFunc = function()
|
||||||
|
self:getServerList()
|
||||||
|
end,
|
||||||
|
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
|
||||||
|
top = true,
|
||||||
|
}
|
||||||
|
GFunc.showMessageBox(params)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
UIManager:hideToast()
|
||||||
|
-- BIReport:postRequestVersionSuccess(self.loginCenterUrl, (os.clock() - self.connectStartTimes)*1000, self.retryTimes - 1)
|
||||||
|
self.accountLoginSuccess = true
|
||||||
|
if self.authSid then
|
||||||
|
self:unscheduleGlobal(self.authSid)
|
||||||
|
self.authSid = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
self.versionInfo = jsonData
|
||||||
|
Logger.printTable(jsonData)
|
||||||
|
self:checkServerOpen()
|
||||||
|
else
|
||||||
|
-- BIReport:postRequestVersionFailed(self.loginCenterUrl, (os.clock() - self.connectStartTimes)*1000, self.retryTimes - 1)
|
||||||
|
local params = {
|
||||||
|
content = I18N:getGlobalText(I18N.GlobalConst.GET_SEVER_ERROR),
|
||||||
|
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
||||||
|
noShowClose = true,
|
||||||
|
okFunc = function()
|
||||||
|
self:getServerList()
|
||||||
|
end,
|
||||||
|
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
|
||||||
|
top = true,
|
||||||
|
}
|
||||||
|
GFunc.showMessageBox(params)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if self.authSid then
|
||||||
|
self:unscheduleGlobal(self.authSid)
|
||||||
|
end
|
||||||
|
self.authSid = self:performWithDelayGlobal(function()
|
||||||
|
-- BIReport:postRequestVersionFailed(self.loginCenterUrl, (os.clock() - self.connectStartTimes)*1000, self.retryTimes - 1)
|
||||||
|
local params = {
|
||||||
|
content = I18N:getGlobalText(I18N.GlobalConst.GET_SEVER_ERROR),
|
||||||
|
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
||||||
|
noShowClose = true,
|
||||||
|
okFunc = function()
|
||||||
|
self:getServerList()
|
||||||
|
end,
|
||||||
|
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
|
||||||
|
top = true,
|
||||||
|
}
|
||||||
|
GFunc.showMessageBox(params)
|
||||||
|
end, 5)
|
||||||
|
end
|
||||||
|
|
||||||
return LoginManager
|
return LoginManager
|
||||||
@ -11,6 +11,7 @@ function LoginUI:getPrefabPath()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function LoginUI:onClose()
|
function LoginUI:onClose()
|
||||||
|
ModuleManager.LoginManager:removeAllLoginData()
|
||||||
end
|
end
|
||||||
|
|
||||||
function LoginUI:onLoadRootComplete()
|
function LoginUI:onLoadRootComplete()
|
||||||
@ -26,6 +27,8 @@ function LoginUI:onLoadRootComplete()
|
|||||||
self.progressTx:setText("")
|
self.progressTx:setText("")
|
||||||
uiMap["login_ui.loading_text"]:setText(I18N:getGlobalText(I18N.GlobalConst.LOADING_DESC))
|
uiMap["login_ui.loading_text"]:setText(I18N:getGlobalText(I18N.GlobalConst.LOADING_DESC))
|
||||||
|
|
||||||
|
self:initListener()
|
||||||
|
|
||||||
local distinctId = LocalData:getDistinctId()
|
local distinctId = LocalData:getDistinctId()
|
||||||
if distinctId == nil or distinctId == "" then
|
if distinctId == nil or distinctId == "" then
|
||||||
distinctId = CS.ThinkingAnalytics.ThinkingAnalyticsAPI.GetDistinctId()
|
distinctId = CS.ThinkingAnalytics.ThinkingAnalyticsAPI.GetDistinctId()
|
||||||
@ -49,10 +52,30 @@ function LoginUI:onLoadRootComplete()
|
|||||||
GFunc.copyStr(distinctId)
|
GFunc.copyStr(distinctId)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
ModuleManager.LoginManager:resetServerListStartTime()
|
||||||
|
ModuleManager.LoginManager:addServerListCallback(function(serverList)
|
||||||
|
if EDITOR_MODE then
|
||||||
|
Logger.logHighlight("------------serverList------------")
|
||||||
|
Logger.printTable(serverList)
|
||||||
|
end
|
||||||
|
|
||||||
|
self:refreshServerList(serverList)
|
||||||
|
ModuleManager.LoginManager:saveAuthArgs()
|
||||||
|
ModuleManager.LoginManager:initSocket()
|
||||||
|
|
||||||
|
local info = LocalData:getLastLoginInfo()
|
||||||
|
BIReport:postAccountLoginClick(info.type)
|
||||||
|
end)
|
||||||
|
ModuleManager.LoginManager:getServerList()
|
||||||
|
|
||||||
CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc()
|
CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc()
|
||||||
LocalData:save()
|
LocalData:save()
|
||||||
|
end
|
||||||
|
|
||||||
self:preloadAndEnterMaincity()
|
function LoginUI:initListener()
|
||||||
|
self:addEventListener(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS, function()
|
||||||
|
self:preloadAndEnterMaincity()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function LoginUI:preloadAndEnterMaincity()
|
function LoginUI:preloadAndEnterMaincity()
|
||||||
@ -103,4 +126,19 @@ function LoginUI:updateProgress()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function LoginUI:refreshServerList(serverList)
|
||||||
|
self.serverList = serverList or {}
|
||||||
|
if not ModuleManager.LoginManager.selectIndex or ModuleManager.LoginManager.selectIndex <= 0 then
|
||||||
|
ModuleManager.LoginManager.selectIndex = 1
|
||||||
|
else
|
||||||
|
ModuleManager.LoginManager.selectIndex = ModuleManager.LoginManager.selectIndex + 1
|
||||||
|
end
|
||||||
|
if ModuleManager.LoginManager.selectIndex > #self.serverList then
|
||||||
|
ModuleManager.LoginManager.selectIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local defaultUrl = self.serverList[ModuleManager.LoginManager.selectIndex].url
|
||||||
|
LocalData:setString(LocalData.KEYS.GATE, defaultUrl)
|
||||||
|
end
|
||||||
|
|
||||||
return LoginUI
|
return LoginUI
|
||||||
@ -11,6 +11,7 @@ function TestLoginUI:getPrefabPath()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TestLoginUI:onClose()
|
function TestLoginUI:onClose()
|
||||||
|
ModuleManager.LoginManager:removeAllLoginData()
|
||||||
if self.dropList then
|
if self.dropList then
|
||||||
self.dropList.onValueChanged:RemoveAllListeners()
|
self.dropList.onValueChanged:RemoveAllListeners()
|
||||||
end
|
end
|
||||||
@ -53,15 +54,33 @@ function TestLoginUI:onLoadRootComplete()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
self:addEventListener(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS, function()
|
||||||
|
self:preloadAndEnterMaincity()
|
||||||
|
end)
|
||||||
|
|
||||||
local accountId = LocalData:getAccountInfo().id or GConst.EMPTY_STRING
|
local accountId = LocalData:getAccountInfo().id or GConst.EMPTY_STRING
|
||||||
local copyTx = uiMap["test_login_ui.copy_account_tx"]
|
local copyTx = uiMap["test_login_ui.copy_account_tx"]
|
||||||
copyTx:setVisible(accountId ~= GConst.EMPTY_STRING)
|
copyTx:setVisible(accountId ~= GConst.EMPTY_STRING)
|
||||||
copyTx:addClickListener(function()
|
copyTx:addClickListener(function()
|
||||||
GFunc.copyStr(accountId)
|
GFunc.copyStr(accountId)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
ModuleManager.LoginManager:resetServerListStartTime()
|
||||||
|
ModuleManager.LoginManager:addServerListCallback(function(serverList)
|
||||||
|
self:refreshServerList(serverList)
|
||||||
|
end)
|
||||||
|
ModuleManager.LoginManager:getServerList()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TestLoginUI:loginGame()
|
function TestLoginUI:loginGame()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
local name = uiMap["test_login_ui.login_node.input_field"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text
|
||||||
|
if name == "" then
|
||||||
|
name = nil
|
||||||
|
end
|
||||||
|
-- ModuleManager.LoginManager:saveAuthArgs(name)
|
||||||
|
-- ModuleManager.LoginManager:initSocket()
|
||||||
|
|
||||||
self.uiMap["test_login_ui.login_node.login_btn"]:setTouchEnable(false)
|
self.uiMap["test_login_ui.login_node.login_btn"]:setTouchEnable(false)
|
||||||
-- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查
|
-- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查
|
||||||
CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc()
|
CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc()
|
||||||
|
|||||||
1170
lua/app/net/net_manager.lua
Normal file
1170
lua/app/net/net_manager.lua
Normal file
File diff suppressed because it is too large
Load Diff
10
lua/app/net/net_manager.lua.meta
Normal file
10
lua/app/net/net_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03c05c9e525f1184a9df9e3de931efa8
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
Loading…
x
Reference in New Issue
Block a user