local Login_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local Login_Implement = require("Modules/Login/Login_Implement") local HttpReq = require('Http/HttpReq') local LuaFuncEntry = require("Main/LuaFuncEntry") --优化之前的存储记录方式 之前只是简单的记录了count 但是策划邀请可能大版本更新cg时 新老玩家都要测重置次数 --后续如果还有这个需求 就只换JWS2_LoginCG_Count_Data 里的name名字 --2023/4/19 第一版 诸葛亮版本 name ZhuGeLiangCG local JWS2_LoginCG_Count = "JWS2_LoginCG_Count_Data" --SSL使用的证书,用来验证客户端身份, 有效期结束时需要热更更换 local TcpConnectionSSLStr = "5zzX3fzajG---Y24-UZ4UzQ91fq0je---Yjqbbo55zzXU1--jJ24-UZ4UzQ91fq0aZ--jJj8bbHFjbqj5zz1dflXBWMzmAwkjfwa5a84-EZ4UzQ91fq5jfl81bfzF3ipf3UuJIq-jbbjbzz1nXGGxmEjn2rtDO3NWdjMSYu7ux-wvNbhtRl_CjNi6eQIheTeWzqs3m4Ljk3MpG_rhWabrecZJxQUm7cXZcQQPN72sRsS_CyGM0pn-FP6x6qxsKFdBAMLJWbqztlkVSCnzdAWP9Ws9n0TSymgCxaBOsBjTfj4oUAoYvAI8qJbPjVdJh5n9MYjCQN_dsw6r7Z-DiiVh5F7VNEqGoG8wuHlj7ATAIA3VxWwxiOOk9jrv6Q_bqIW_pr_QiwtPqxqOod5QcR81EnW1CPQHBRaxzso7c1S2ifYIQipsGeLiYoAfnko2wB1nPt8tbaT0PA-U6M3kFZSqCELcYHv7yIHrnzgKZaSI-TAtP2xSuJk3eN3i1B414jlncvBWDlFCoG8t7JsnrtUhpNNUt3FKf-im47f151fCovqRaOuUMVoQ2eM9kfbE_I5ONnjYKYtBnpiQW54HbBAdAYmAdQsTmNwVyW1W1rOf30OPAWmomm0XUnu90YuzVGV_4DL2YcUNi3T6X-Qq59KfjeX4LOkKGMgupq5hHfS-LABC7ARgJizdrLAOSikoeST4Or4c0W6fEddYEpdRjTW3pAfnzyuSuqxsfEfAgNzKXi2iCyrK_zqbnwnOBfB_6vTbx37euRPxjgTg9qJ06dJi309RX0pqvUP52R8RaQSRTFGQ7KpTAQ7f0aEQD901uUiaVFAWZu2fCevqeQ6l0MPjTYAK_RTHrlPf4fq7nfvVkywh6uW1CURZJOIuTWcGF7eoyux4kB2pbzowNNUQD6T3TBtnQpL-1fUj09g7bViMqveU0-i1CqPlkfreg6K-Az3s8sH1cOajFDe1JGfmtucHOfZ6iAKr78ls8nYboTCrXZepK1c-YrlGaZV2no0wni06vXGBw-5W058MO3vLSNZqSyJNo9pq-on6MDwW60M1ITwGnf1ypeHp2n8e0ASHtL8k55cTA2At1jiLc07YvuOEhtIkHlziLexIFW-he5ZdWXRQ5sHehu7B_UJdiuL1_bi0t8Rc-NjlOPfbb20mIBvMkNZcpjViZfnDR3kTOY2wAjeD3552ithkp_RF_nzOZYE8erWO_Db_nvl9hikVF_80ZVD4Eov8YOrJxycuIoBej41JJKD_2QIGgcT-YjShfAAhCOMboRI593pXYoxKZ6O7CQ3sa7ueKysS8uq5jMpr1k1ExDXctXgQXvE4nG5B22BZp-ZbbdLpYuAv5grSJqxWRf7RGPOcyD391OlsnvzKCHHKgL2yfA4vZ6Z4Q_sgsned_FyWk88bbYaabxZmxE4u8taa84bbbThazzDOs--aUW8bbT3abFZmxE4u8ta1jWajZ--aNr8bbiZ5a84-EZ4UzQ91fq5jf581bfzWhy4rLdo3Iz-jbbjazzqhjlnlEgq5_XsBLI6unfQbp0Tricp3qIlngDtiDfnWmfSl1xE1N5sFtUR87ER73pSadqKdjfAWNVY3L3GgCWljk4l0iChZt9v9EPYlWZl6F-v18Ck6--tlmN7_Yx7WxS9L4M7tlC2rAMNu0XYeEYazUtL0T11oMxtwP0csg8XdMxbq1YfE6PURpJp2lk7cjImvVmf5CgE-IDCUu_WyIwjPiLgA3DRhgkxhdC2Glycl8uI4j1zG1ZwhRbOf0xNyBObKc9caj7j1_vsWSd0mWUGfSIz3b2Aw9GiPOo9hoKivlr3hM9kdHAHmY_0_9ecL1Wl1wZ9eAR7Gh8upAIrnlhhBwMVfTrpheKBkB4bCOSngVwOR1G6FnwaFH8VqJIFRr6eViEWf2zYm6gogLu1-U5PgIogLr-5uSaJ3a2hI4Z1IULvufnAcYLVWBbwBx50woM9c13jdM0GSrdzwRXHa6PLNaw9nlFJWA-lANf-uJPyFxt3wL3sBxxmRS6CSqKsX2q_vlLQYv4QtvHrGn62TvJaA3uEmXqVcg3Jv6eynzxauHJfu34MrHXJbr6sTpLmsTxBhUGwHKE8SYAcOu5CQNsqEItFbKjKV_67Otpkr7SyaiShgcxr3ngWwAUGsiDugT2KcR9RJggBrlgYdAL5DNOwKi_RjDTJCNjBKj-5i_XAX_OXqIwechfGMXCI4pYgXjj8MMF8AQR6q369M5vpuut1xGINbg2RZjUqP8BS3re016RrCTgNUuim6A4ohHUoAl7L1u5zBU3m6hovcWVDZiUIk-01mMr4lII79d9f5q8GyA76Jgcu3YlCVb7lDiBfaek1uX88Ij1y-1r493xqe7gHq4BQHlLOf6hRX_0naXH_73ycT10kPVqOWIMvxfM3-bOfbo-fZQxyHrlZYsFLM5XGmRSGtN6Q0ZP9GTAq80esFXo3h9zgbQ4cmfp_tl3b4n3e2HKWjkrktyi3DK8AmSGeu2i5i51L78jVp1eUutjsNELoku8bThKW-RRMOJocOCNO5g-Cx__UY3716CCsTb3ipH_X3yRzrC8sSv7X53e8VNSMFLrYYurmpt9CVeVaLGiH7NwJ2uu6zvWEicLTZ2hfDiagsguc3TBtKUWlpzUJtwh8hEHzhfhZfULOvk3n_GIap4ywAWbpQiZqlEef2MDPS1UxfSthZg_iv61YdL1H6jrvOTAuJf-OgRSmhzocpBY-Ad05NuSCTXrh8HNk2iq9yB-0Cu2mcQEh5N-07LpOAdmdwIj7WASiglmnOuscKKbV5eiLtUHoCs6J-e5auaB-Tx_BVz1QYo5uT1KM7f9YKR4FSte0hUykK2KHWCBdeaDPwB6zx-TlDFqUSt8LkrkNyxJ6sQBBtx2Ty0GQZktX57OPz3MLT5vnrvz7hQDJjawvJZ7QHVup1xvOuuhwyJ-QXl_iObsbtSfeQrU1GGg-q8w9EmVQWqSlyZ1DQi2oV-xxCsw2nmlK97WDyxPgq6vssZp4XfQABnJjFp4BXC4ihP0rJJFpbheOUEsJeNWw4Tg7jxp6rIjd61dwyafFeA96dNetHmY-mxKYJp028ET_id9qqjJMmfleOlK-Sb53xYjQNANn4Uuvk_gmWNeOuclNLnhLbFHvvFBMJiqo5-54-UZ4UzQ91fqXDiqgaaU6oTtxVD6CsidjZRbVW_9MGkk2Lij65-q8-flDB8r1jmWDjjfTi0vpx2QevKT9BPKL-R0bF1E3J5lq-k7iEMY0xqeqjbzzjj==" local LOGIN_BG_STATIC_PIC = ConstAssetPathConfig.LOGIN_BG_STATIC_PIC1 --国内热更大小小于该值时播放背景音乐 local LOGIN_BG_STATIC_HOTFIXSIZE_CN = 30 --海外热更大小小于10M显示静态图 local LOGIN_BG_STATIC_HOTFIXSIZE_OVERSIZE = 10 local JWS2_LoginCG_Count_Data = {name = "ZhuGeLiangCG", count = 0} Login_Controller.AnnouncementKind = { SystemNoticeKind_Public = 0, -- 普通 SystemNoticeKind_Maintaince = 1, -- 维护 SystemNoticeKind_Forceupdate = 2, -- 强更 SystemNoticeKind_Obstruct = 4, --阻挡 SystemNoticeKind_JapanUpdate = 5, -- 日服更新预告 } local JSON = require("cjson") local curKind = nil private.isFirstClose = true private.authErrorCount = 0 private.isFierceServerOpen = true --激战区服务器是否开启入口 private.isFierceServerRegion = false --当前选择的是否激战区 private.hasInitFierceServerRegion = false --是否已经初始化过大区选择 local INFO_WAITING_KEY = "INFO_WAITING" local CONNECT_WAITING_KEY = "CONNECT_WAITING" local WAITTING_CONTEXT = { isOnlyShow = true } Login_Controller.InfoTypeEnum = { Connecting = 1, Warn = 2, Error = 3, } private.hasSendBI_StartGetPADProgress = false --PAD回调队列 private._padCallbackParamList = {} --PAD回调执行计时timer private._padCallbackParamConsumeTimer = nil Login_Controller.PadCallbackTypeEnum = { UpdatePadStatus = 1, UpdatePadProgress = 2, } private.assetPackInfo = nil local PAD_REQUEST_DELAY = 20 local PAD_REQUEST_CHECK = 20 local PAD_CHECK_INFO_KEY = "PAD_CHECK_INFO" local OPEN_PAD_CHECK = false --是否开启pad校验 --谷歌PAD下载的错误码和状态码 local AndroidAssetPackError = { InternalError = -100, AppNotOwned = -13, NetworkUnrestricted = -12, PlayStoreNotFound = -11, InsufficientStorage = -10, AccessDenied = -7, NetworkError = -6, ApiNotAvailable = -5, DownloadNotFound = -4, InvalidRequest = -3, PackUnavailable = -2, AppUnavailable = -1, NoError = 0, } local AndroidAssetPackStatus = { Unknown = 0, Pending = 1, Downloading = 2, Transferring = 3, Completed = 4, Failed = 5, Canceled = 6, WaitingForWifi = 7, NotInstalled = 8, } private.lastDisplayPadDownloadProgress = 0 private.isRequestingMobileData = false private.padRequestHandle = nil private.checkPadCallbackHandle = nil local lastReqTime = 0 local ReqTimeInterval = 1 local SendTime = {} local NoticeCustomer = nil Login_Controller.IsClickNotice = false --强制热更经由kickpush流程的错误码 local ForceBundleUpdateKickErrCode = 12 --控制请求域名开关,当服务器host出问题时,将此处关了热更 local TaiHttpRequireHostSwitch = true --变体表更新总开关 local VariantDataUpdateSwitch = true --地区变体表名后缀:k-Global_ProductId v-后缀 local VariantSheetSuffix = { ["62"] = "_AME", --美服 ["63"] = "_EMEA", --欧服 } --地区变体表 覆盖原始表部分行数据 local VariantCoverDiffSheetData = { ["62"] = { "TimeRefresh", "MultiplayerDungeon", "WorldBoss", }, ["63"] = { "MultiplayerDungeon", "WorldBoss", }, } --地区变体表 覆盖原始表所有数据 local VariantCoverWholeSheetData = { ["62"] = { "TeamLevelData", }, ["63"] = { "TeamLevelData", }, } local macIsQuerySkuDetails = false function Login_Controller.OnStartup() private.SetupEntryFunc(true) if USE_AAB_SMALL_PAD == nil or USE_AAB_SMALL_PAD == false then --大pad模式,0050版本7个pack if GameAppInfo.IsVersionGreaterThan15000() then private.assetPackInfo = { AssetPack1 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack2 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack3 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack4 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack5 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack6 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack7 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, } else private.assetPackInfo = { AssetPack1 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack2 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack3 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack4 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack5 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack6 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, } end else private.assetPackInfo = { AssetPack1 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, AssetPack2 = { totalSize = 0, downloadSize = 0, isComplete = false, packPath = "" }, } end EventSystem.Regist(EventID.UI_SplashComplete, private.OnSplashComplete) NetManager.RegisterMsgCB(MessageEnums.MessageKick, private.OnKickPush) EventSystem.Regist(EventID.PCPackage_NTLoginSuccess, private.OnNTLoginSuccess) end function private.SetupEntryFunc(isRegist) LuaFuncEntry.SetupMainEntryFunc(isRegist, LuaFuncEntry.FuncType.OnLoadGameLevel, Login_Controller.OnLoadGameLevel, LuaFuncEntry.FuncType.ConnectingUI, Login_Controller.OpenConnectingPanel, LuaFuncEntry.FuncType.OnPadMobileDataRequestResult, private.OnPadMobileDataRequestResult, LuaFuncEntry.FuncType.OnIOSCellularDataStateChange, private.OnIOSCellularDataStateChange, LuaFuncEntry.FuncType.SDKAuthInfoRequest, private.SDKAuthInfoRequest, LuaFuncEntry.FuncType.SDKLoginFailed, private.OnSdkLoginFailed, LuaFuncEntry.FuncType.OnPADCheckResult, private.OnPADCheckResult, LuaFuncEntry.FuncType.OnOpenQrCodeError, private.OnOpenQrCodeError, LuaFuncEntry.FuncType.OnSwitchCDNUrl, MDL.Login.SwitchCDNBaseUrl, LuaFuncEntry.FuncType.SendEnterWorld, private.SendEnterWorld, LuaFuncEntry.FuncType.UpdatePadStatus, private.HandleUpdatePadStatus, LuaFuncEntry.FuncType.UpdatePadProgress, private.HandleUpdatePadProgress ) end function Login_Controller.OnShutdown() private.SetupEntryFunc(false) end function private.SendEnterWorld() MDL.Login.SendEnterWorld(false, 0) end function private.HandleUpdatePadStatus(...) private.AddOnePADCallbackParam(Login_Controller.PadCallbackTypeEnum.UpdatePadStatus, ...) end function private.HandleUpdatePadProgress(...) private.AddOnePADCallbackParam(Login_Controller.PadCallbackTypeEnum.UpdatePadProgress, ...) end function private.SDKAuthInfoRequest(...) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) MDL.Login.SDKAuthInfoRequest(...) end --sdk登录失败有两种,1登录失败,2登录取消 function private.OnSdkLoginFailed(isCancelLogin, errorMsg) logging.crit(LTAG.CRIT, "OnSdkLoginFailed", errorMsg) local channelID = SDKUtil.ChannelID if isCancelLogin and channelID == LuaConst.SDKChannelId.TencentYYB then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Login_SDKFailHint) return end UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_Login_SDKFailHint, function() SDKUtil.AutoLogin() end, nil, UTL.MessageBox.DisplayType.SDKLoginFailed) --此处加判空处理,是为了解决低版本取消崩溃的问题,ios底层不能有空 CTL.Setting.UploadLog(CTL.Setting.UploadLogProblemType.LoginFailed, errorMsg or "") end function private.OnOpenQrCodeError(errorCode) EventSystem.Dispatch(EventID.PCPackage_OpenQrCodeError, errorCode) end function Login_Controller.GetHttpRequireHost() -- 是否尝试请求域名,返回1为请求,非1不请求 if TaiHttpRequireHostSwitch and GameAppInfo.IsVersionGreaterThan121000() then return 1 end return 0 end --region AAB-PAD下载 function private.StartPADDownload() logging.crit(LTAG.CRIT, "StartPADDownload") CTL.Loading.BeginLoading(MDL.Loading.LoadingTypeEnum.FastFollowAssetPack) private.padCheckInfo = PersistentData.DeviceData:Get(PAD_CHECK_INFO_KEY) if private.padCheckInfo then if private.padCheckInfo.marketVersion ~= AppInfo.marketVersion then --如果保存校验结果的版本与当前版本不一致,需要重置 private.padCheckInfo = { marketVersion = AppInfo.marketVersion } end else private.padCheckInfo = { marketVersion = AppInfo.marketVersion } end BIManager.SendDownloadEvent(101, 0) private.TryCompleteAABRes() end function private.TryCompleteAABRes() private.StartCheckPadCallbackHandle() LoginProxy.TryCompleteAABRes() end function private.StopPadRequestHandle() if private.padRequestHandle then TimerUtil.Remove(private.padRequestHandle) private.padRequestHandle = nil end end function private.StartPadRequestHandle() if private.padRequestHandle == nil then private.padRequestHandle = TimerUtil.Interval(private.TryCompleteAABRes, PAD_REQUEST_DELAY, 1) end end function private.StopCheckPadCallbackHandle() if private.checkPadCallbackHandle then TimerUtil.Remove(private.checkPadCallbackHandle) private.checkPadCallbackHandle = nil end end function private.StartCheckPadCallbackHandle() if not NetManager.IsValidNet() then UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_AABDownload_Tips_1, private.StartPadRequestHandle) else if private.checkPadCallbackHandle == nil then private.checkPadCallbackHandle = TimerUtil.Interval(private.TryCompleteAABRes, PAD_REQUEST_CHECK, 1) end end end function private.QuitPad() LoginProxy.CancelPadDownload() private.QuitGame() end function private.CancelToContinue(packName) LoginProxy.CancelPadDownload() private.StartPadRequestHandle() end --pad下载后台也会下载,放到一个队列里通过Unity引擎的update执行,可以防止后台的情况下仍然在执行逻辑 function private.AddOnePADCallbackParam(...) table.insert(private._padCallbackParamList, {...}) if not private._padCallbackParamConsumeTimer then private._padCallbackParamConsumeTimer = TimerUtil.Update(private.OnPADCallbackTimerCallback) end end function private.OnPADCallbackTimerCallback() local padCallbackParam = table.remove(private._padCallbackParamList, 1) if padCallbackParam then private.ExcutePadCallback(table.unpack(padCallbackParam)) else TimerUtil.RemoveUpdate(private._padCallbackParamConsumeTimer) private._padCallbackParamConsumeTimer = nil end end function private.ExcutePadCallback(callbackType, ...) if callbackType == Login_Controller.PadCallbackTypeEnum.UpdatePadStatus then private.UpdatePadStatus(...) elseif callbackType == Login_Controller.PadCallbackTypeEnum.UpdatePadProgress then private.UpdatePadProgress(...) end end function private.UpdatePadStatus(packName, errorCode, statusCode) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) private.StopPadRequestHandle() private.StopCheckPadCallbackHandle() if errorCode ~= AndroidAssetPackError.NoError then logging.error(LTAG.ERROR, "AndroidAssetPackError", packName, errorCode) if errorCode == AndroidAssetPackError.InsufficientStorage then --提示玩家清理磁盘 UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_AABDownload_Tips_4, private.QuitPad) elseif errorCode == AndroidAssetPackError.AppNotOwned or errorCode == AndroidAssetPackError.AccessDenied then --谷歌账号与app不匹配,或者账号无权限 UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_AABDownload_Tips_3, private.QuitPad) elseif errorCode == AndroidAssetPackError.NetworkUnrestricted or errorCode == AndroidAssetPackError.NetworkError then UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_AABDownload_Tips_1, private.StartPadRequestHandle) elseif errorCode == AndroidAssetPackError.InternalError then private.CancelToContinue(packName) else UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_AABDownload_Tips_5, private.QuitPad) end else local isCheck = false if statusCode == AndroidAssetPackStatus.Completed then if OPEN_PAD_CHECK and GameAppInfo.IsVersionGreaterThan111000() then if private.HasPackCheck(packName) == false then LoginProxy.AsyncCheckPad(packName) else if private.CompleteFastFollow(packName) == false then isCheck = true end end else if private.CompleteFastFollow(packName) == false then isCheck = true end end elseif statusCode == AndroidAssetPackStatus.WaitingForWifi then --防止请求多次 if private.isRequestingMobileData == false then LoginProxy.RequestToUseMobileData() private.isRequestingMobileData = true end elseif statusCode == AndroidAssetPackStatus.Unknown or statusCode == AndroidAssetPackStatus.Failed or statusCode == AndroidAssetPackStatus.NotInstalled then logging.error(LTAG.ERROR, "AndroidAssetPackStatus", packName, statusCode) private.StartPadRequestHandle() else isCheck = true end if isCheck then private.StartCheckPadCallbackHandle() end end end function private.OnPADCheckResult(packName, result) logging.crit(LTAG.CRIT, "OnPADCheckResult:", packName, result) if result then private.padCheckInfo[packName] = LoginProxy.GetAssetPackPath(packName) PersistentData.DeviceData:Set(PAD_CHECK_INFO_KEY, private.padCheckInfo, true) if private.CompleteFastFollow(packName) == false then private.StartCheckPadCallbackHandle() end else --校验失败,重新移除再下 LoginProxy.RemoveAssetPack(packName) private.StartCheckPadCallbackHandle() end end function private.HasPackCheck(packName) local checkedPackPath = private.padCheckInfo[packName] if checkedPackPath then return checkedPackPath == LoginProxy.GetAssetPackPath(packName) end return false end --玩家取消了流量下载,弹窗提示 function private.OnPadMobileDataRequestResult(result) private.isRequestingMobileData = false if result == false then UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_AABDownload_Tips_2, private.TryCompleteAABRes) end end function private.CompleteFastFollow(packName) local packPath = LoginProxy.GetAssetPackPath(packName) logging.crit(LTAG.CRIT, "CompleteFastFollow:", packName, "PackPath:", packPath) --有些设备在清了文件数据之后,这里仍然直接返回了Complete,这里加个保护 if string.isNilOrEmpty(packPath) then LoginProxy.RemoveAssetPack(packName) return false end local isAllComplete = true for i, v in pairs(private.assetPackInfo) do if v.isComplete == false then isAllComplete = false break end end if isAllComplete then return true end isAllComplete = true private.assetPackInfo[packName].isComplete = true private.assetPackInfo[packName].packPath = packPath for i, v in pairs(private.assetPackInfo) do if v.isComplete == false then isAllComplete = false break end end if isAllComplete then local path1 = private.assetPackInfo.AssetPack1.packPath local path2 = private.assetPackInfo.AssetPack2.packPath if USE_AAB_SMALL_PAD == nil or USE_AAB_SMALL_PAD == false then local path3 = private.assetPackInfo.AssetPack3.packPath local path4 = private.assetPackInfo.AssetPack4.packPath local path5 = private.assetPackInfo.AssetPack5.packPath local path6 = private.assetPackInfo.AssetPack6.packPath if GameAppInfo.IsVersionGreaterThan15000() then local path7 = private.assetPackInfo.AssetPack7.packPath LoginProxy.SetBundleInPadPath(path1, path2, path3, path4, path5, path6, path7) else LoginProxy.SetBundleInPadPath(path1, path2, path3, path4, path5, path6) end else LoginProxy.SetBundleInPadPath(path1, path2) end if GameAppInfo.IsVersionGreaterThan114000() then --从140分包优化之后,PAD中不再有音效资源,因此不需要对PAD音效进行初始化 else private.InitPadVoice(path1, path2) end BIManager.SendDownloadEvent(106, 0) logging.crit(LTAG.CRIT, "OnPADDownloadFinish") private.OnPADDownloadFinish() end return isAllComplete end function private.InitPadVoice(path1, path2) CTL.Sound.SetPadPath(path1 .. "/Audio/GeneratedSoundBanks/Android") CTL.Sound.SetPadPath(path2 .. "/Audio/GeneratedSoundBanks/Android") SoundUtil.StopAll() SoundUtil.ResetSoundEngine() CTL.Sound.Init() end function private.UpdatePadProgress(packName, downloadSize, totalSize) if private.hasSendBI_StartGetPADProgress == false then BIManager.SendDownloadEvent(107, 0) private.hasSendBI_StartGetPADProgress = true end private.assetPackInfo[packName].downloadSize = downloadSize private.assetPackInfo[packName].totalSize = totalSize local sumPackSize = 0 local sumDownloadPackSize = 0 for i, v in pairs(private.assetPackInfo) do sumPackSize = sumPackSize + v.totalSize sumDownloadPackSize = sumDownloadPackSize + v.downloadSize end local curDisplayProgress = sumDownloadPackSize / sumPackSize if private.lastDisplayPadDownloadProgress < 0.1 and curDisplayProgress >= 0.1 then BIManager.SendDownloadEvent(102, 0) end if private.lastDisplayPadDownloadProgress < 0.2 and curDisplayProgress >= 0.2 then BIManager.SendDownloadEvent(103, 0) end if private.lastDisplayPadDownloadProgress < 0.4 and curDisplayProgress >= 0.4 then BIManager.SendDownloadEvent(104, 0) end if private.lastDisplayPadDownloadProgress < 0.8 and curDisplayProgress >= 0.8 then BIManager.SendDownloadEvent(105, 0) end EventSystem.Dispatch(EventID.UI_Loading_UpdateFastFollowProgress, curDisplayProgress, sumDownloadPackSize, sumPackSize) private.lastDisplayPadDownloadProgress = curDisplayProgress end --endregion AAB-PAD下载 function Login_Controller.Start() private.SetDataSheetManagerVarientInfo() if GameAppInfo.IsVersionGreaterThan114000() then --快手渠道改为MediaPlayer模式,否则会崩溃,渠道反馈没有对sdk库进行裁剪,如果需要修,需要配合 if SDKUtil.ChannelID == LuaConst.SDKChannelId.KuaiShou or SDKUtil.ChannelID == LuaConst.SDKChannelId.HuaWei then AuxUtil.SetTimelineVideoAPI(1) else AuxUtil.SetTimelineVideoAPI(2) end end UnityEngine.SceneManagement.SceneManager.LoadScene("Login") logging.crit(LTAG.CRIT, "ChannelID", SDKUtil.ChannelID, "SubChannelID", SDKUtil.SubChannelID) AuxUtil.BuglyAgentAddSceneData("ChannelID", SDKUtil.ChannelID) SDKUtil.ShowDoubleService(GameAppInfo.Global_ProductId) private.OnSplashComplete() end function private.SetDataSheetManagerVarientInfo() if not VariantDataUpdateSwitch then return end if GameAppInfo.IsOverseaPackage() then local productId = GameAppInfo.Global_ProductId if VariantCoverDiffSheetData[productId] then DataSheetManager.SetVariantDiffSheetInfo(VariantCoverDiffSheetData[productId], VariantSheetSuffix[productId]) end if VariantCoverWholeSheetData[productId] then DataSheetManager.SetVariantCoverWholeSheetInfo(VariantCoverWholeSheetData[productId], VariantSheetSuffix[productId]) end end end function private.OnSplashComplete() AuxUtil.ReloadLanguage(Const_IDS) CTL.Sound.Init() private.SetUploadParam() CameraController.LoadGameCamera() --这里如果是PC扫码包,先播CG再弹出扫码界面,再公告 if not CTL.WinLogin.TryWinGameStart() then private.EnterLogin() end private.QuerySkuDetails() end function private.OnNTLoginSuccess() private.EnterLogin() end function private.EnterLogin() if SettingAPI.deviceLevel == 0 then AuxUtil.StopSSS() end CTL.Loading.BeginLoading(MDL.Loading.LoadingTypeEnum.None) NetManager.Init() NetManager.SetIsLaunch(true) MDL.Login.InitPackageCfgUrlList() Login_Controller.StartGetGamePackageCfg() end --开始拉取公告(热更)逻辑 function Login_Controller.StartGetGamePackageCfg() if not NetManager.IsValidNet() then Login_Controller.OpenErrorWarnPanel(Const_IDS.IDS_TIPS_WIFI_CHECK, Login_Controller.StartGetGamePackageCfg) if UNITY_IOS and private.IsHasNetworkAccessUpdateNotifierFunc() then SDKUtil.GetNetworkAccessUpdateNotifier() end else Login_Controller.OpenConnectingPanel(true) Login_Controller.GetGamePackageCfg() end end function private.IsHasNetworkAccessUpdateNotifierFunc() if GameAppInfo.IsOverseaPackage() then return GameAppInfo.IsVersionGreaterThan15000() else return GameAppInfo.IsVersionGreaterThan14100() end end --restrictedStateUnknown = 0 未知情况 (还没有遇到推测是有网络但是连接不正常的情况下) --restricted = 1 关闭网络 或者只选择wifi联网 返回1 --notRestricted = 2 开启wifi和移动网络 返回2 --这个回调是在执行的时候立马给一次回调 然后每次网络选项变化时又给一次 --所以第一安装启动调用接口 返回1 然后选择仅wifi或者拒绝都返回1 选择wifi和移动网络返回2 --本来想根据返回值判断但是考虑一下可以根据回调里是否有网去做判断 因为1有可能是拒绝权限 或者直选wifi 拿是否能联网直接判断 --流程case 启动app 弹出网络网络连接失败弹窗 并且弹出ios系统选择网络弹窗 选择wifi 或者蜂窝 回调该接口 --如果NetManager.IsValidNet()返回true 关闭网络失败弹窗 开始请求公告 --如果NetManager.IsValidNet()返回 false 网络失败弹窗不关闭 --选择不允许任何网络 不回调该接口 网络失败弹窗不关闭 function private.OnIOSCellularDataStateChange(state) logging.crit(LTAG.CRIT, " OnIOSCellularDataStateChange ", state) if not private.IOSValidNet then if NetManager.IsValidNet() then private.IOSValidNet = true UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) CTL.Login.StartGetGamePackageCfg() else if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIMessageBoxView) then CTL.Login.OpenErrorWarnPanel(Const_IDS.IDS_TIPS_WIFI_CHECK, CTL.Login.StartGetGamePackageCfg) end end end end function Login_Controller.OnLoadGameLevel(netValid, acid) logging.crit(LTAG.CRIT, "OnLoadGameLevel", acid) --进度条40之前是加载系统模块和所有AB,40之后是连接服务器,初始化协议内容 CTL.Loading.SetLoginLoadingProgress(0.4) Login_Controller.LaunchModules() --和服务器连接成功后,已经发过来acid了 NotSyncBattleSetter.SetAcid(acid) if BattleDataGetter.IsOnlinePlay() then --在线流程 if netValid then MDL.Login.SendEnterWorld(false, 0) end else --离线流程 NetManager.SendMessage = function(id,msg) logging.log(LTAG.LOG, "离线实验室不发 proto :",id) end LevelPlayerManager.SetLaboratoryHeroTable() LevelManager.SwitchLevel(201) AuxUtil.WarmUpShaders() end end --登录成功后,require系统模块 function Login_Controller.LaunchModules() Login_Controller.HandleEndLogin() require("Common/define") --如果是市场PC录屏包,特殊处理一下 if GameAppInfo.IsMarketPackage() then private.SpecialInitPCMarket() end CTL.Loading.BeginLoading(MDL.Loading.LoadingTypeEnum.EnterWorld) EventSystem.Dispatch(EventID.UI_Loading_UpdateTips, Const_IDS.IDS_LoginTips) Modules.Launch() --延时到游戏启动后再设置LOD,希望的启动时使用高质量的参数 CTL.Setting.LoginSync() end function private.SpecialInitPCMarket() DataSheetUtil.DataSheetPCMarketProcess() LevelManager.IsNeedUsePVPModelLevel = function() return false end end --公告是否过期 function Login_Controller.IsAnnouncementInTime(beginTime, endTime) local serverTime = MDL.Login.AnnounceServerTime if serverTime >= beginTime and serverTime < endTime then return true end return false end function private.QuitGame() UIUtils.QuitGame() end --检测安装包是否过期 function Login_Controller.CheckPackageTimeExpire(time) if not UNITY_EDITOR then if time and DEF.Package_BuildTime < time then local func = string.isNilOrEmpty(MDL.Login.ForceUpdateURL) and private.QuitGame or Login_Controller.OpenForceupdateUrl UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_LoginTimeOut, func) return true end end return false end --公告拉取,回调处理 function Login_Controller.SyncAnnouncementList(annStr, serverTime, clientExpireTime) --安装包过期 if Login_Controller.CheckPackageTimeExpire(clientExpireTime) then return end local list = MDL.Login.SyncAnnouncementList(annStr) MDL.Login.AnnounceServerTime = serverTime curKind = Login_Controller.AnnouncementKind.SystemNoticeKind_Public --公告类型:强更>阻挡>维护>普通=日服更新预告 for i, v in ipairs(list) do local beginTime = v.Begin local endTime = v.End if Login_Controller.IsAnnouncementInTime(beginTime, endTime) then local kind = v.Kind if kind == Login_Controller.AnnouncementKind.SystemNoticeKind_Forceupdate then curKind = Login_Controller.AnnouncementKind.SystemNoticeKind_Forceupdate break else if kind > curKind then if kind == Login_Controller.AnnouncementKind.SystemNoticeKind_JapanUpdate then if curKind == SystemNoticeKind_Public then curKind = Login_Controller.AnnouncementKind.SystemNoticeKind_JapanUpdate end else curKind = kind end end end else logging.error(LTAG.ERROR, "announcement is out of date,index is ", i) end end --跳转强更链接 if curKind == Login_Controller.AnnouncementKind.SystemNoticeKind_Forceupdate then CTL.Loading.EndLoading() UIManager.OpenView(Const_UI_Lua.UIEnum.UIForceUpdateTip) return end -- 设置SSL使用的证书 private.InitTcpConnectionSSLStr() --检测资源更新 if CTL.HotFix.CheckHotFix() then return end Login_Controller.OnHotFixFinish() end --登录前下载分两个步骤:1、热更,2检测pad --若检测无热更则执行此方法,有热更的时候热更完会重启游戏,因此不执行此方法 --无热更分两种情况,一种是不开启热更,一种是已经更到了最新 --热更结束开始检测pad,pad仅在谷歌包中使用,其他直接调用该步骤的结束 function Login_Controller.OnHotFixFinish() local lastPkgVer = LuaExt.FileReadText("pkgver") or "" LuaExt.FileWriteText("pkgver", AppInfo.marketVersion) if LoginProxy.GetIsForceAppDataPath() then logging.crit(LTAG.CRIT, string.format("package version changed, from %s to %s, without hotfix", lastPkgVer, AppInfo.marketVersion)) --当前是覆盖安装,到这个阶段之前资源全是用的包内的,需要改成【优先包外】模式并重启生效 LoginProxy.SetIsForceAppDataPath(false) LuaNetManager.RebootGame(true) return end private.LoadResAfterHotfix() --安卓aab检测PAD下载 --防止刷新公告的时候重走了一遍PAD检测,导致关闭了服务器界面 if UNITY_ANDROID and AppInfo.isBuildAAB and not Login_Controller.IsClickNotice and not DEF.USE_SMALL_APK and not DEF.USE_AAB_NOT_PAD then private.StartPADDownload() else private.OnPADDownloadFinish() end end function private.OnPADDownloadFinish() if GameAppInfo.IsVersionGreaterThan111000() then LoginProxy.FinishAllPadCheck() end CTL.HotFix.OnPADFinish() --开服阻挡公告 if curKind == Login_Controller.AnnouncementKind.SystemNoticeKind_Obstruct then private.hasObstruct = true --开启预下载 CTL.HotFix.PreDownloadStage() Login_Controller.ShowLoginUI() return end BIManager.LastUpdateStepTime = os.time() BIManager.DispatchBIClientEvent(BIManager.EventName.BDC_StartHotUpdate, BIManager.BDCEventParam.update_id, BIManager.BDCEventParamValue.BeginCheckUpdate, BIManager.BDCEventParam.update_state, BIManager.BDCEventParamValue.Update_State_Success, BIManager.BDCEventParam.duration_time, "0") --分包1未下载完 AuxUtil.BuglyAgentAddSceneData("PackageStage", tostring(LoginProxy.GetCurStage())) if not DEF.USE_SMALL_APK and private.OnDownloadFirstPack() then return end Login_Controller.ShowLoginUI() end function private.OnDownloadFirstPack() if CTL.HotFix.Get_IsFirstPackageComplete() == false then logging.crit(LTAG.CRIT, "OnDownloadFirstPack") --分包的Loading CTL.Loading.BeginLoading(MDL.Loading.LoadingTypeEnum.StagePackage, CTL.Loading.PackDownloadType.Video) CTL.HotFix.ContinueDownloadStage() return true end return false end function Login_Controller.ShowLoginBgByHotfixSize(hotfixSize) if GameAppInfo.IsChinesePackage() then --国内热更较小时,音效反馈可以不播放背景音乐 CTL.Login.ShowLoginMoviePanel(MDL.Login.LoginBGTypeEnum.Video, MDL.Login.GetLoginShowPath(), hotfixSize 0 then local errorIDS = "IDS_ERROR_NETWORK_AUTH_"..errorCode if not Const_IDS[errorIDS] then errorIDS = "IDS_ErrorLoginTips" end if not UNITY_EDITOR and not UNITY_STANDALONE then UTL.MessageBox.ShowOnlyOkNoCloseBox(IDS_COMMON_PROMPT, Const_IDS[errorIDS], Login_Controller.ClientReAuth, Const_IDS.IDS_BUTTON_CONFIRM) else UTL.MessageBox.ShowOnlyOkBox(IDS_COMMON_PROMPT, Const_IDS[errorIDS], nil, Const_IDS.IDS_BUTTON_CONFIRM) end else Login_Controller.ClientReAuth() private.authErrorCount = private.authErrorCount + 1 end EventSystem.Dispatch(EventID.SDKUrlMonitor_ReqUrlFail, LuaConst.SDKMonitorTriggerType.Auth) end function Login_Controller.ClientReAuth() private.authErrorCount = 0 Login_Implement.ClientReAuthRequest() end function Login_Controller.OpenSelectServerPanel() if Login_Controller.IsFierceServerOpen() and private.isFierceServerRegion then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UILoginSelectServerVirtualGidC) then UIManager.OpenView(Const_UI_Lua.UIEnum.UILoginSelectServerVirtualGidC) end else if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UILoginSelectServer) then UIManager.OpenView(Const_UI_Lua.UIEnum.UILoginSelectServer) end end end function Login_Controller.IsFierceServerOpen() return private.isFierceServerOpen and GameAppInfo.IsChinesePackage() end function Login_Controller.IsFierceServerRegion() return private.isFierceServerRegion end function Login_Controller.InitFierceServerRegionStatus(flag) if not private.hasInitFierceServerRegion then private.hasInitFierceServerRegion = true private.isFierceServerRegion = flag end end function Login_Controller.ResetInitFierceServerRegion() private.hasInitFierceServerRegion = false UIManager.CloseView(Const_UI_Lua.UIEnum.UILoginSelectServer) UIManager.CloseView(Const_UI_Lua.UIEnum.UILoginSelectServerVirtualGidC) UIManager.CloseView(Const_UI_Lua.UIEnum.UISelectRegionViewVirtualGidC) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) end --luaConsole测试用 function Login_Controller.SetFierceServerRegion(flag) private.isFierceServerOpen = flag end function Login_Controller.ChangeSelectServerPanel(index) if index == 1 then private.isFierceServerRegion = true if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UILoginSelectServerVirtualGidC) then UIManager.OpenView(Const_UI_Lua.UIEnum.UILoginSelectServerVirtualGidC) end UIManager.CloseView(Const_UI_Lua.UIEnum.UILoginSelectServer) else private.isFierceServerRegion = false if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UILoginSelectServer) then UIManager.OpenView(Const_UI_Lua.UIEnum.UILoginSelectServer) end UIManager.CloseView(Const_UI_Lua.UIEnum.UILoginSelectServerVirtualGidC) end UIManager.CloseView(Const_UI_Lua.UIEnum.UISelectRegionViewVirtualGidC) end function Login_Controller.OpenInfoPanel(typeEnum, isActive, desc, clickHandler) if isActive then if typeEnum == Login_Controller.InfoTypeEnum.Connecting then UTL.MessageBox.ShowWaitingWithDelay(INFO_WAITING_KEY, WAITTING_CONTEXT) else UTL.MessageBox.ShowOnlyOkNoCloseBox("", desc, clickHandler) end else UTL.MessageBox.CloseWaitingWithDelay(INFO_WAITING_KEY) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) end end function Login_Controller.OpenConnectingPanel(isActive) if isActive then UTL.MessageBox.ShowWaitingWithDelay(CONNECT_WAITING_KEY, WAITTING_CONTEXT) else UTL.MessageBox.CloseWaitingWithDelay(CONNECT_WAITING_KEY) end end function Login_Controller.OpenErrorWarnPanel(desc, clickHandler, cancelHandler) if clickHandler and cancelHandler then UTL.MessageBox.ShowOKCancelNoCloseBox("", desc, clickHandler, cancelHandler) else UTL.MessageBox.ShowOnlyOkNoCloseBox("", desc, clickHandler) end end function private.OnKickPush(msg) local Disconnect_KickByServer = 6 LuaNetManager.Disconnect(Disconnect_KickByServer, true) LuaNetManager.KickPush() MultiplayManager.CloseKCP() private.KickErrorCode = msg.KickErrCode local info = nil if private.KickErrorCode == ForceBundleUpdateKickErrCode then info = Const_IDS.IDS_StrongUpdate else info = Const_IDS["IDS_LOGIN_TIPS_KICKNOTIFY_"..msg.KickErrCode] end BIManager.DispatchBIClientEvent(BIManager.EventName.OnKickPush) TimerUtil.Clear() UTL.MessageBox.ShowOnlyOkNoCloseBox(Const_IDS.IDS_WARNING, info, private.BackToLogin) EventSystem.Dispatch(EventID.BI_ClientNetState, NetManager.NetStateCode.Normal, NetManager.NetStateCode.Normal, NetManager.DisconnectReason.KickByServer) end function private.BackToLogin() local KickErrorCode = private.KickErrorCode private.KickErrorCode = nil if GameAppInfo.IsPCPackageWithSdk() and KickErrorCode == 9 then --PC顶号的时候不清空平台登录信息 LuaNetManager.RebootGame() elseif GameAppInfo.IsJapanesePackage() and KickErrorCode == 10 then --日本舆情功能的踢回登录,无论任何登录方式,都会强行登出,游客登录方式无提示绑定账号弹窗 SDKUtil.LogoutAnyway() else SDKUtil.SwitchAccount() end end -----------------------------------以下是登录流程------------------------------------------- --region 将所有的cdn地址配置到了一个公用的地址,此处是拉取这个配置 function Login_Controller.GetGamePackageCfg() -- Local bypass is kept for emergency tests; normal dev now uses packagecfg/CDN. if DEF.Package_PostType == "dev_local" then DEF.DISABLE_ASSET_CHECK = true local serverNoticeData = { Endpoint = {}, chatIp = "192.168.55.136:10001", ServerTime = tostring(UTL.Time.GetLocalTimestamp()), time_zone = 7, } serverNoticeData.Endpoint[GameAppInfo.Global_ProductId] = "http://192.168.55.136:8081" MDL.Login.IsGetAnnouncementCfg = true Login_Controller.OpenConnectingPanel(false) private.SetAppDataByServerNotice(serverNoticeData) Login_Controller.SyncAnnouncementList("[]", tonumber(serverNoticeData.ServerTime), 0) return end local localTimeStamp = UTL.Time.GetLocalTimestamp() local timeStr = os.date(UTL.Time.FormatDateEnum.MDHM, localTimeStamp) local url if DEF.Package_PostType == "dev" then url = string.format(MDL.Login.GetPackageCfgUrl(), "default", timeStr) elseif GameAppInfo.IsGameStreamerPackage() then --主播包其实配置和国服是一样的,强制用国服的,暂时不用运维添加了 url = string.format(MDL.Login.GetPackageCfgUrl(), "cn", timeStr) else url = string.format(MDL.Login.GetPackageCfgUrl(), Localization.GetRegionName(), timeStr) end --此处发送ReqPackageCfg打点 BIManager.SendWithEncode(BIManager.EventName.ReqPackageCfg, "url", url) --https://jws2-global.taiplat.com/cdn/default/packagecfg.json?v=09/25 10:07 Login_Implement.StartGetGamePackageCfg(url, private.OnGamePackageCfgComplete, private.OnGamePackageCfgFail) logging.crit(LTAG.CRIT, "Start GetGamePackageCfg") end --获取CDN配置文件完成回调,成功获取公告服地址 function private.OnGamePackageCfgComplete(gamePackageCfgStr, url) logging.crit(LTAG.CRIT, "GetGamePackageCfg Success") --此处发送RespPackageCfgSuccess打点 BIManager.SendWithEncode(BIManager.EventName.RespPackageCfgSuccess) if not string.isNilOrEmpty(gamePackageCfgStr) then local gamePackageCfg = JSON.decode(gamePackageCfgStr) if not gamePackageCfg then private.OnGamePackageCfgFail(10005, "\n解析GamePackageCfg失败", gamePackageCfgStr, url) elseif gamePackageCfg.baseurl then MDL.Login.SetCDNBaseUrlList(gamePackageCfg.baseurl) MDL.HotFix.InitHotFixUrl() Login_Controller.GetEntryAddress() else private.OnGamePackageCfgFail(10005, "\nGamePackageCfg缺少baseurl字段", gamePackageCfgStr, url) end else private.OnGamePackageCfgFail(10005, "\n未请求到GamePackageCfg", "", url) end end --获取CDN配置文件失败回调,没有获取到auth function private.OnGamePackageCfgFail(errorCode, exception, stackTrace, failedURL) logging.crit(LTAG.CRIT, "GetGamePackageCfg Fail") --此处发送RespPackageCfgFail打点 BIManager.SendWithEncode(BIManager.EventName.RespPackageCfgFail, "errorcode", errorCode, "failedURL", failedURL) MDL.Login.SwitchPackageCfgUrl() Login_Controller.OpenConnectingPanel(false) local tipErrorMsg = UTL.String.GetErrorCodeMsg(10005) Login_Controller.OpenErrorWarnPanel(tipErrorMsg, Login_Controller.StartGetGamePackageCfg, private.QuitGame) CTL.Loading.EndLoading() EventSystem.Dispatch(EventID.SDKUrlMonitor_ReqUrlFail, LuaConst.SDKMonitorTriggerType.PackageCfgUrl) logging.crit(LTAG.CRIT, exception, stackTrace, failedURL) end function Login_Controller.GetEntryAddress() local localTimeStamp = UTL.Time.GetLocalTimestamp() local timeStr = os.date(UTL.Time.FormatDateEnum.MDHM, localTimeStamp) local entryAddressUrl if DEF.Package_PostType=="dev" then entryAddressUrl = string.format(MDL.Login.CDNFileCfgUrlFormat, MDL.Login.GetCDNBaseUrl(), "default", DEF.Package_PostType, timeStr) elseif GameAppInfo.IsGameStreamerPackage() then --主播包其实配置和国服是一样的,强制用国服的,暂时不用运维添加了 entryAddressUrl = string.format(MDL.Login.CDNFileCfgUrlFormat, MDL.Login.GetCDNBaseUrl(), "cn", DEF.Package_PostType, timeStr) else entryAddressUrl = string.format(MDL.Login.CDNFileCfgUrlFormat, MDL.Login.GetCDNBaseUrl(), Localization.GetRegionName(), DEF.Package_PostType, timeStr) end BIManager.SendWithEncode(BIManager.EventName.ReqEntryAddress, "url", entryAddressUrl) Login_Implement.StartGetEntryAddressCfg(entryAddressUrl, private.OnEntryAddressCfgComplete,private.OnEntryAddressCfgFail) logging.crit(LTAG.CRIT, "Start GetEntryAddress") end --获取CDN配置文件完成回调,成功获取公告服地址 function private.OnEntryAddressCfgComplete(entryAddressCfgStr, url) logging.crit(LTAG.CRIT, "GetEntryAddress Success") if not string.isNilOrEmpty(entryAddressCfgStr) then local entryAddressCfg = JSON.decode(entryAddressCfgStr) if not entryAddressCfg then private.HandleAnnounceError(10005, url, "\n解析EntryAddressCfg失败", entryAddressCfg, url) elseif entryAddressCfg.notice and entryAddressCfg.notice[GameAppInfo.Global_ProductId] then BIManager.SetBIUrl(entryAddressCfg.bi[GameAppInfo.Global_ProductId]) private.GetAnnouncement(entryAddressCfg.notice[GameAppInfo.Global_ProductId]) else private.HandleAnnounceError(10005, url, "\nEntryAddressCfg缺少大区公告服配置", entryAddressCfg, url) end if entryAddressCfg.ping and entryAddressCfg.ping[GameAppInfo.Global_ProductId] then EventSystem.Dispatch(EventID.SDKUrlMonitor_RegistMonitorUrl, LuaConst.SDKMonitorType.Game, entryAddressCfg.ping[GameAppInfo.Global_ProductId]) end else private.HandleAnnounceError(10005, url, "\n未请求到EntryAddressCfg", "", url) end BIManager.SendWithEncode(BIManager.EventName.RespEntryAddressSuccess) end --获取CDN配置文件失败回调,没有获取到auth function private.OnEntryAddressCfgFail(errorCode, exception, stackTrace, failedURL) logging.crit(LTAG.CRIT, "GetEntryAddress Fail") private.HandleAnnounceError(errorCode,failedURL, "拉取EntryAddressCfg失败") MDL.Login.SwitchCDNBaseUrl() EventSystem.Dispatch(EventID.SDKUrlMonitor_ReqUrlFail, LuaConst.SDKMonitorTriggerType.CDN) end function private.HandleAnnounceError(errorCode, failedURL, ...) --上报CDN配置文件获取的错误 BIManager.SendWithEncode(BIManager.EventName.RespEntryAddressFail, "errorcode", errorCode, "failedURL", failedURL) Login_Controller.OpenConnectingPanel(false) local tipErrorMsg = UTL.String.GetErrorCodeMsg(errorCode) Login_Controller.OpenErrorWarnPanel(tipErrorMsg, Login_Controller.GetEntryAddress, private.QuitGame) CTL.Loading.EndLoading() logging.crit(LTAG.CRIT, failedURL, ...) end --endregion CDN --region *************** 公告 *************** function private.GetAnnouncement(address) if string.sub(address, string.len(address)) == "/" then address = string.sub(address, 0, string.len(address)-1) end local url = string.format(MDL.Login.NoticeCfgUrlFormat, address, GameAppInfo.Global_ProductId, AppInfo.marketVersion, SDKUtil.ChannelID, SDKUtil.ProjectID, Localization.GetLanguage2Server(), SDKUtil.SubChannelID or "", GameAppInfo.GetPlatform()) BIManager.SendWithEncode(BIManager.EventName.ReqAnnouncement, "url", url) Login_Implement.StartGetAnnouncemenCfg(url, private.OnGetAnnouncementCfgComplete, private.OnGetAnnouncementCfgFail) logging.crit(LTAG.CRIT, "Start GetAnnouncement") end --服务器公告回调,成功获取到公告 function private.OnGetAnnouncementCfgComplete(serverNoticeJsonStr, url) logging.crit(LTAG.CRIT, "GetAnnouncement Success") Login_Controller.OpenConnectingPanel(false) if not string.isNilOrEmpty(serverNoticeJsonStr) then local serverNoticeData = JSON.decode(serverNoticeJsonStr) --PC放出去直接就是线上,不需要提审 if (not GameAppInfo.IsPCPackage() or CTL.WinLogin.IsUsePCNtSdk()) and serverNoticeData and not string.isNilOrEmpty(serverNoticeData.URL) then MDL.Login.IsReviewService = true --有新的公告地址,需要跳转新的公告 CTL.HotFix.SetOpenTipAllNet(true) private.GetAnnouncement(serverNoticeData.URL) return end if not serverNoticeData or not serverNoticeData.Endpoint then private.HandleAuthError(10005, url, "\n解析公告信息失败", serverNoticeJsonStr) else MDL.Login.IsGetAnnouncementCfg = true BIManager.SendWithEncode(BIManager.EventName.RespAnnouncementSuccess) private.SetAppDataByServerNotice(serverNoticeData) end else private.HandleAuthError(10005, url, "\n拉取公告信息失败") end end --服务器公告回调,获取公告失败 function private.OnGetAnnouncementCfgFail(errorCode, exception, stackTrace, failedURL) logging.crit(LTAG.CRIT, "GetAnnouncement Fail") Login_Controller.OpenConnectingPanel(false) private.HandleAuthError(errorCode, failedURL, "拉取公告信息失败", exception, stackTrace) end function private.HandleAuthError(errorCode, failedURL, ...) --上报公告配置文件获取的错误 BIManager.SendWithEncode(BIManager.EventName.RespAnnouncementFail, "errorcode", errorCode, "failedURL", failedURL) local errorMsg = "" if Const_IDS["IDS_ERROR_NETWORK_AUTH_" .. errorCode] then errorMsg = UIUtils.GetLocalizedTxt(Const_IDS["IDS_ERROR_NETWORK_AUTH_" .. errorCode]) else errorMsg = string.gsub(UIUtils.GetLocalizedTxt(Const_IDS["IDS_ERROR_NETWORK_AUTH"]), "{0}", errorCode) end Login_Controller.OpenErrorWarnPanel(errorMsg, Login_Controller.GetEntryAddress) CTL.Loading.EndLoading() EventSystem.Dispatch(EventID.SDKUrlMonitor_ReqUrlFail, LuaConst.SDKMonitorTriggerType.Announcement) logging.crit(LTAG.CRIT, failedURL, ...) end --设置服务器公告数据 function private.SetAppDataByServerNotice(serverNoticeData) logging.log(LTAG.LOG, serverNoticeData) NoticeCustomer = serverNoticeData.NoticeCustomer MDL.WinLogin.SetShowScanChannels(serverNoticeData.WinScanSwitch) if not string.isNilOrEmpty(serverNoticeData.Chatserver) then AppInfo.chatServerURL = serverNoticeData.Chatserver end if serverNoticeData.time_zone then UTL.Time.SetTimeZoneByServer(serverNoticeData.time_zone, tonumber(serverNoticeData.ServerTime)) end if serverNoticeData.PayUrls and serverNoticeData.PayUrls["default"] then SDKUtil.SetPayCallBackURL(serverNoticeData.PayUrls["default"]) end private.SetHotfixCode(serverNoticeData) if DEF.HOTFIX_USE_VER then AppInfo.hotfixCodeFromServer = DEF.HOTFIX_USE_VER end --加个保护,如果热更包未配置热更号,弹窗拦截 if not UNITY_EDITOR and (string.isNilOrEmpty(AppInfo.hotfixCodeFromServer) and DEF.DISABLE_ASSET_CHECK == nil) then UTL.MessageBox.ShowOnlyOkNoCloseBox("check update info failed", "deploy hotfix code and relogin", Login_Controller.GetEntryAddress) return end private.SetPreHotfixCode(serverNoticeData) BIManager.SetABTestMode(Login_Controller.GetLocalABTestMode()) if not string.isNilOrEmpty(serverNoticeData.TimeoutTime) then local timeOutTime = tonumber(serverNoticeData.TimeoutTime) LuaNetManager.SetNetMessageTimeOutMax(timeOutTime > 0 and timeOutTime or 30) NetManager.NetMessageTimeOutMax = timeOutTime > 0 and timeOutTime or 30 end if not string.isNilOrEmpty(serverNoticeData.TokenTime) then local tokenTimeout = tonumber(serverNoticeData.TokenTime) AppInfo.tokenTimeout = tokenTimeout > 0 and tokenTimeout or 12900 end if not string.isNilOrEmpty(serverNoticeData.ForceUpdateURL) then MDL.Login.ForceUpdateURL = serverNoticeData.ForceUpdateURL end if not string.isNilOrEmpty(serverNoticeData.Whitelistpwd) then MDL.Login.WhiteListPwd = serverNoticeData.Whitelistpwd end local serverTime = 0 if not string.isNilOrEmpty(serverNoticeData.ServerTime) then serverTime = tonumber(serverNoticeData.ServerTime) --更新下本地存储的服务器时间 UTL.Time.UpdateServerTimestamp(serverTime) --判断客户端服务器时间是否相差过大,发给BI和TD local clientTime = UTL.Time.GetLocalTimestamp() local csTimeDiff = serverTime - clientTime if csTimeDiff >= 5 or csTimeDiff <= -5 then MDL.Login.HasClientServerTimeDiffErrorReported = true BIManager.DispatchBIClientEvent(BIManager.EventName.ClientServerTimeDiff, "clienttime", tostring(clientTime), "servertime", tostring(serverNoticeData.ServerTime), "difftime", tostring(clientTime-serverNoticeData.ServerTime)) end end local clientExpireTime = 0 if not string.isNilOrEmpty(serverNoticeData.clientExpireTime) then clientExpireTime = tonumber(serverNoticeData.clientExpireTime) end if serverNoticeData.Endpoint then --serverNoticeData.Endpoint[GameAppInfo.Global_ProductId] = "http://185.238.249.111:22301" serverNoticeData.Endpoint[GameAppInfo.Global_ProductId] = "http://192.168.55.136:8081" local url = serverNoticeData.Endpoint[GameAppInfo.Global_ProductId] if url then AppInfo.endpointURL = url end end if not string.isNilOrEmpty(serverNoticeData.chatIp) then LoginProxy.SetChatIP(serverNoticeData.chatIp) end if serverNoticeData.Publics then Login_Controller.SyncAnnouncementList(JSON.encode(serverNoticeData.Publics), serverTime, clientExpireTime) end if not string.isNilOrEmpty(serverNoticeData.AndroidPrivacySwitch) or not string.isNilOrEmpty(serverNoticeData.IosPrivacySwitch) then private.AndroidPrivarySwitch = serverNoticeData.AndroidPrivacySwitch == "true" private.IOSPrivarySwitch = serverNoticeData.IosPrivacySwitch == "true" EventSystem.Dispatch(EventID.UI_Login_PrivacySwitchUpdate) end end function Login_Controller.GetAndroidPrivarySwitch() return private.AndroidPrivarySwitch or false end function Login_Controller.GetIOSPrivarySwitch() return private.IOSPrivarySwitch or false end function Login_Controller.SetInputWhiteList(inputWhiteList) return Login_Implement.SetInputWhiteList(inputWhiteList) end function Login_Controller.HasWhiteListBase64Input() return Login_Implement.HasWhiteListBase64Input() end --针对不同平台拿到不同的热更号 function Login_Controller.GetPlatformHotVer(content) local platformPattern if UNITY_ANDROID then platformPattern = "^(%w*)|%w*|%w*$" elseif UNITY_IOS then platformPattern = "^%w*|(%w*)|%w*$" else platformPattern = "^%w*|%w*|(%w*)$" end local ver = string.match(content, platformPattern, 1) return ver end --针对不同平台拿到不同的热更号 function Login_Controller.NewGetPlatformHotVer(content) local vers = string.split(content, "|") local platformPattern if UNITY_ANDROID then return vers[1] elseif UNITY_IOS then return vers[2] elseif UNITY_STANDALONE == "OSX" then return vers[4] else return vers[3] end end function private.SetHotfixCode(serverNoticeData) local noticeBundle = GameAppInfo.IsMacPackage() and serverNoticeData.BundleNew or serverNoticeData.Bundle if not string.isNilOrEmpty(noticeBundle) then local ver = GameAppInfo.IsMacPackage() and Login_Controller.NewGetPlatformHotVer(noticeBundle) or Login_Controller.GetPlatformHotVer(noticeBundle) if ver then AppInfo.hotfixCodeFromServer = ver else logging.error(LTAG.ERROR, "hotfix ver match failed", noticeBundle) end end end function private.SetPreHotfixCode(serverNoticeData) local preHotfixCode = GameAppInfo.IsMacPackage() and serverNoticeData.PreHotfixNew or serverNoticeData.PreHotfix if not string.isNilOrEmpty(preHotfixCode) then local ver = GameAppInfo.IsMacPackage() and Login_Controller.NewGetPlatformHotVer(preHotfixCode) or Login_Controller.GetPlatformHotVer(preHotfixCode) if ver then CTL.HotFix.SetPreHotfixCode(ver) else logging.error(LTAG.ERROR, "pre hotfix ver match failed", preHotfixCode) end end end --endregion 公告 function Login_Controller.RequestServerList() local localTime = UTL.Time.GetLocalTimestamp() if localTime - lastReqTime >= ReqTimeInterval then Login_Implement.RequestServerList() lastReqTime = localTime end end function private.SetUploadParam() local prefix = UTL.Time.OsDateOriginal("log-", os.time()) SDKUtil.SetUploadParam(prefix, 5, 5) end ---大区切换过相关 function Login_Controller.PingRequest(url, timeoutValue) local handle = HttpReq.Create(url, HttpReq.HTTPMethods.Get, private.OnPingCallback) HttpReq.Send(handle) SendTime[handle] = Time.realtimeSinceStartup * 1000 TimerUtil.Interval(function () if SendTime[handle] then HttpReq.Abort(handle) SendTime[handle] = nil EventSystem.Dispatch(EventID.OnPingRequestFinish, handle, -1) end end, timeoutValue, 1) return handle end function private.OnPingCallback(handle, success, state, absoluteUri, message, respCode, respJson) local ping = -1 if state == HttpReq.HTTPRequestState.Finished then if success then ping = Time.realtimeSinceStartup * 1000 - SendTime[handle] end end SendTime[handle] = nil EventSystem.Dispatch(EventID.OnPingRequestFinish, handle, ping) end function Login_Controller.SelectRegion(regionNumber) if GameAppInfo.Global_ProductId ~= regionNumber then GameAppInfo.ResetProductId(regionNumber) Localization.SaveRegion() LuaNetManager.RebootGame() end end --登录界面是否显示客服按钮 2是关 非2开 function Login_Controller.IsShowCustomerBtn() return NoticeCustomer ~= 2 end function private.InitEmojiText() if GameAppInfo.IsOverseaPackage() then if GameAppInfo.IsVersionGreaterThan15000() then UIUtils.InitEmojiTagChar("@") end elseif GameAppInfo.IsVersionGreaterThan14100() then UIUtils.InitEmojiTagChar("@") end if GameAppInfo.IsVersionGreaterThan113000() then UIUtils.InitEmojiIndex() end end function private.InitTcpConnectionSSLStr() if GameAppInfo.IsVersionGreaterThan121000() then UIUtils.InitTcpConnectionSSLStr(TcpConnectionSSLStr) end end function Login_Controller.IsSpServerOpen(serverList, id) for i, server in ipairs(serverList) do if tonumber(server["group_id"]) == id then return true end end return false end --mac包启动时要去查掉单信息 通过这个接口查询,所以需要提前 function private.QuerySkuDetails() if GameAppInfo.IsMacPackage() and not macIsQuerySkuDetails then local str = "" local count = DataSheetManager.IAP:GetDataCount() for i, v in DataSheetManager.IAP:GetEnumerator() do if i == count then str = str .. v.IapID else str = str .. v.IapID .. ";" end end logging.crit(LTAG.CRIT, "login QuerySkuDetails") SDKUtil.QuerySkuDetails(str) end end function Login_Controller.OnGetSkuDetail(jsonStr) logging.crit(LTAG.CRIT, "login OnGetSkuDetail") macIsQuerySkuDetails = true private.macSkuDetailJsonStr = jsonStr end function Login_Controller.GetMacSkuDetailJsonStr() return private.macSkuDetailJsonStr end return Login_Controller