diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index 5c665561..2bad0d02 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -188,6 +188,14 @@ function DataManager:initWithServerData(data) self.initWithServer = true end +function DataManager:setAuthInfo(authInfo) + self.authInfo = authInfo +end + +function DataManager:getAuthInfo() + return self.authInfo +end + -- 是否首次登录 function DataManager:getIsFirstLogin() local nowTime = Time:getServerTime() diff --git a/lua/app/common/event_manager.lua b/lua/app/common/event_manager.lua index f4a358dd..f00a138c 100644 --- a/lua/app/common/event_manager.lua +++ b/lua/app/common/event_manager.lua @@ -79,6 +79,7 @@ EventManager.CUSTOM_EVENT = { FORCE_SUMMON_NEXT_FINISH = "FORCE_SUMMON_NEXT_FINISH", FORCE_SUMMON_CHECK_PATH = "FORCE_SUMMON_CHECK_PATH", FORCE_SUMMON_CHECK_PATH_GM = "FORCE_SUMMON_CHECK_PATH_GM", + UPDATE_SIDE_BAR = "UPDATE_SIDE_BAR", CROSS_DAY = "CROSS_DAY",-- 跨天 } diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index 12e4c845..3a8afb04 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -292,7 +292,7 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId) -- 检查是否可以支付 SDKManager:checkPay(productId, function(code) if code == 0 then - self:sendMessage(ProtoMsgType.FromMsgEnum.ActPayReq, {id = id, act_type = purchaseType}, {}, function(binder, msgData) + self:sendMessage(ProtoMsgType.FromMsgEnum.ActPayReq, {id = id, act_type = purchaseType}, function(binder, msgData) if msgData.status == 0 then if msgData.uuid and msgData.uuid ~= GConst.EMPTY_STRING then local giftType = PayManager:getGiftType(purchaseType, id) @@ -323,7 +323,7 @@ end function PayManager:sendMsgToServer(purchaseToken, uuid, originOrderId, productId, callback) local args = SDKManager:getPurchaseArgs(purchaseToken, uuid, originOrderId, productId) - self:sendMessage(ProtoMsgType.FromMsgEnum.ActPaidResultReq, args, {}, callback) + self:sendMessage(ProtoMsgType.FromMsgEnum.ActPaidResultReq, args, callback) end return PayManager \ No newline at end of file diff --git a/lua/app/module/account/account_manager.lua b/lua/app/module/account/account_manager.lua index bb238678..bf84a3fe 100644 --- a/lua/app/module/account/account_manager.lua +++ b/lua/app/module/account/account_manager.lua @@ -20,7 +20,7 @@ function AccountManager:getIsBinded() end function AccountManager:deleteAccount() - self:sendMessage(ProtoMsgType.FromMsgEnum.DeleteReq, {}, {}, self.onDeleteAccount, BIReport.ITEM_GET_TYPE.NONE) + self:sendMessage(ProtoMsgType.FromMsgEnum.DeleteReq, {}, self.onDeleteAccount, BIReport.ITEM_GET_TYPE.NONE) end function AccountManager:onDeleteAccount(result) @@ -52,7 +52,7 @@ function AccountManager:bindAccount() id = params.id, token = params.token } - self:sendMessage(ProtoMsgType.FromMsgEnum.BindReq, args, {}, self.onBindAccount, BIReport.ITEM_GET_TYPE.NONE) + self:sendMessage(ProtoMsgType.FromMsgEnum.BindReq, args, self.onBindAccount, BIReport.ITEM_GET_TYPE.NONE) end, loginType) end @@ -128,7 +128,7 @@ function AccountManager:changeAccount() id = params.id, token = params.token } - self:sendMessage(ProtoMsgType.FromMsgEnum.ExistReq, args, {}, self.onChangeAccount, BIReport.ITEM_GET_TYPE.NONE) + self:sendMessage(ProtoMsgType.FromMsgEnum.ExistReq, args, self.onChangeAccount, BIReport.ITEM_GET_TYPE.NONE) end, loginType) end diff --git a/lua/app/module/activity/act_sprint/act_sprint_manager.lua b/lua/app/module/activity/act_sprint/act_sprint_manager.lua index 97a051db..34f6a2cd 100644 --- a/lua/app/module/activity/act_sprint/act_sprint_manager.lua +++ b/lua/app/module/activity/act_sprint/act_sprint_manager.lua @@ -188,4 +188,78 @@ function ActSprintManager:onBuyBountyPro(giftId) PayManager:purchasePackage(giftId, PayManager.PURCHARSE_TYPE.ACT_GIFT, true) end +--region 打点 +BIReport.ACT_SPRINT_OPT_TYPE = { + SPRINT_REWARD = "SprintReward", + SPRINT_TASK = "SprintTask", + NORMAL_TASK = "NormalTask", + SIGN_BOUNTY = "SignBounty", +} + +-- 冲刺活动 +BIReport.ITEM_GET_TYPE.ACT_SPRINT_EXCHANGE = "act_sprint_exchange" +BIReport.ITEM_GET_TYPE.ACT_SPRINT_STANDARD = "act_sprint_standard" +BIReport.ITEM_GET_TYPE.ACT_SPRINT_TASK = "act_sprint_task" +BIReport.ITEM_GET_TYPE.ACT_SPRINT_GIFT = "act_sprint_gift" +BIReport.ITEM_GET_TYPE.ACT_SPRINT_SIGN_BOX = "act_sprint_sign_box" + +local EVENT_NAME_ACT_SPRINT = "client_act_sprint" + +function BIReport:postActSprintClaimSprintReward(actId, actType, curNum, totalNum, sprintTaskRound, sprintRewardRound) + local args = { + opt_type = BIReport.ACT_SPRINT_OPT_TYPE.SPRINT_REWARD, + act_id = actId, + act_type = actType, + finish_num = curNum, + total_num = totalNum, + sprint_task_round = sprintTaskRound, + sprint_reward_round = sprintRewardRound, + } + self:report(EVENT_NAME_ACT_SPRINT, args) +end + +function BIReport:postActSprintClaimSprintTask(actId, actType, taskIds, curNum, totalNum, sprintTaskRound, sprintRewardRound) + local taskStr = GConst.EMPTY_STRING + for _, taskId in ipairs(taskIds) do + taskStr = taskStr .. tostring(taskId) .. "|" + end + local args = { + opt_type = BIReport.ACT_SPRINT_OPT_TYPE.SPRINT_TASK, + act_id = actId, + act_type = actType, + task_str = taskStr, + finish_num = curNum, + total_num = totalNum, + sprint_task_round = sprintTaskRound, + sprint_reward_round = sprintRewardRound, + } + self:report(EVENT_NAME_ACT_SPRINT, args) +end + +function BIReport:postActSprintClaimNormalTask(actId, actType, taskId, curNum, totalNum, sprintTaskRound, sprintRewardRound) + local args = { + opt_type = BIReport.ACT_SPRINT_OPT_TYPE.NORMAL_TASK, + act_id = actId, + act_type = actType, + task_str = tostring(taskId), + finish_num = curNum, + total_num = totalNum, + sprint_task_round = sprintTaskRound, + sprint_reward_round = sprintRewardRound, + } + self:report(EVENT_NAME_ACT_SPRINT, args) +end + +function BIReport:postActSprintSignBounty(actId, actType, signDay, isPro) + local args = { + opt_type = BIReport.ACT_SPRINT_OPT_TYPE.SIGN_BOUNTY, + act_id = actId, + act_type = actType, + sign_day = signDay, + is_pro = isPro + } + self:report(EVENT_NAME_ACT_SPRINT, args) +end +--endregion + return ActSprintManager \ No newline at end of file diff --git a/lua/app/module/activity/activity_manager.lua b/lua/app/module/activity/activity_manager.lua index 3dc89b86..acdd6119 100644 --- a/lua/app/module/activity/activity_manager.lua +++ b/lua/app/module/activity/activity_manager.lua @@ -43,7 +43,7 @@ function ActivityManager:reqSummerData() if not DataManager.ActivityData:isOpen() then return end - self:sendMessage(ProtoMsgType.FromMsgEnum.SummerDataReq, {}, {}, self.rspSummerData, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.SummerDataReq, {}, self.rspSummerData, nil) end function ActivityManager:rspSummerData(result) @@ -54,7 +54,7 @@ end -- 请求夏日活动任务奖励 function ActivityManager:reqSummerTaskReward(id) - self:sendMessage(ProtoMsgType.FromMsgEnum.SummerTaskClaimReq, {id = id, stage = DataManager.ActivityData:getTaskStage(id)}, {}, self.rspSummerTaskReward, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.SummerTaskClaimReq, {id = id, stage = DataManager.ActivityData:getTaskStage(id)}, self.rspSummerTaskReward, nil) end function ActivityManager:rspSummerTaskReward(result) @@ -67,7 +67,7 @@ end -- 请求夏日活动战令奖励,id为0就是领取档位全部可领奖励 function ActivityManager:reqSummerBountyReward(id, grade) - self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimReq, {id = id, grade = grade}, {}, self.rspSummerBountyReward, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimReq, {id = id, grade = grade}, self.rspSummerBountyReward, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_REWARD) end function ActivityManager:rspSummerBountyReward(result) @@ -96,7 +96,7 @@ function ActivityManager:reqBuyBountyLevel() okFunc = function() local id = DataManager.ActivityData:getBountyCfg()[DataManager.ActivityData:getBountyLevel() + 1].id -- Logger.logHighlight("购买战令等级:"..id) - self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimByDiamondReq, {id = id}, {}, self.rspBuyBountyLevel, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_LEVEL) + self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimByDiamondReq, {id = id}, self.rspBuyBountyLevel, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_LEVEL) end, } GFunc.showMessageBox(params) diff --git a/lua/app/module/arena/arena_bounty_manager.lua b/lua/app/module/arena/arena_bounty_manager.lua index 066c36df..7d1dbb82 100644 --- a/lua/app/module/arena/arena_bounty_manager.lua +++ b/lua/app/module/arena/arena_bounty_manager.lua @@ -14,7 +14,7 @@ function ArenaBountyManager:claimReward(index, isPro) level = index, is_pro = isPro, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ArenaBountyRewardReq, args, {}, self.onClaimReward, BIReport.ITEM_GET_TYPE.ARENA_BOUNTY_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.ArenaBountyRewardReq, args, self.onClaimReward, BIReport.ITEM_GET_TYPE.ARENA_BOUNTY_REWARD) end function ArenaBountyManager:onClaimReward(result) @@ -87,7 +87,7 @@ function ArenaBountyManager:buyBountyLevel() costId = costId, costNum = costNum, okFunc = function() - self:sendMessage(ProtoMsgType.FromMsgEnum.ArenaBountyLevelUnlockReq, {}, {}, self.onBoughtBountyLevel, BIReport.ITEM_GET_TYPE.ARENA_BOUNTY_UNLOCK_LEVEL) + self:sendMessage(ProtoMsgType.FromMsgEnum.ArenaBountyLevelUnlockReq, {}, self.onBoughtBountyLevel, BIReport.ITEM_GET_TYPE.ARENA_BOUNTY_UNLOCK_LEVEL) end, } GFunc.showMessageBox(params) diff --git a/lua/app/module/arena/arena_manager.lua b/lua/app/module/arena/arena_manager.lua index 9399ebaf..d0b0e20d 100644 --- a/lua/app/module/arena/arena_manager.lua +++ b/lua/app/module/arena/arena_manager.lua @@ -50,7 +50,7 @@ end -- 匹配 function ArenaManager:reqMatch() - self:sendMessage(ProtoMsgType.FromMsgEnum.MatchReq, {}, {}, self.rspMatch, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.MatchReq, {}, self.rspMatch, nil) end function ArenaManager:rspMatch(result) @@ -83,7 +83,7 @@ function ArenaManager:reqChallenge() defInfo = DataManager.ArenaData:getMatchInfo() } - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPChallengeStartReq, reqData, {}, self.rspChallenge, BIReport.ITEM_GET_TYPE.ARENA_CHALLENGE) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPChallengeStartReq, reqData, self.rspChallenge, BIReport.ITEM_GET_TYPE.ARENA_CHALLENGE) end function ArenaManager:rspChallenge(result) @@ -128,7 +128,7 @@ function ArenaManager:reqSettlement(win, battleReport, taskProgress) task_stat = taskProgress, battleReport = battleReport, } - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPChallengeSettlementReq, parmas, {}, self.rspSettlement, BIReport.ITEM_GET_TYPE.ARENA_SETTLEMENT) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPChallengeSettlementReq, parmas, self.rspSettlement, BIReport.ITEM_GET_TYPE.ARENA_SETTLEMENT) end function ArenaManager:rspSettlement(result) @@ -167,7 +167,7 @@ end -- 战报 function ArenaManager:reqRecord() - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPRecordHistoryReq, {}, {}, self.rspRecord, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPRecordHistoryReq, {}, self.rspRecord, nil) end function ArenaManager:rspRecord(result) @@ -179,7 +179,7 @@ end -- 排行榜 function ArenaManager:reqRank() - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPRankReq, {}, {}, self.rspRank, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPRankReq, {}, self.rspRank, nil) end function ArenaManager:rspRank(result) @@ -191,7 +191,7 @@ end -- 排行榜玩家编队信息 function ArenaManager:reqRankHeroes(id) - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPRankHeroesReq, {rid = id}, {}, self.rspRankHeroes, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPRankHeroesReq, {rid = id}, self.rspRankHeroes, nil) end function ArenaManager:rspRankHeroes(result) @@ -202,7 +202,7 @@ end -- 领取上赛季奖励 function ArenaManager:reqLastSeasonReward() - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPSeasonRewardReq, {}, {}, self.rspLastSeasonReward, BIReport.ITEM_GET_TYPE.ARENA_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPSeasonRewardReq, {}, self.rspLastSeasonReward, BIReport.ITEM_GET_TYPE.ARENA_REWARD) end function ArenaManager:rspLastSeasonReward(result) @@ -218,7 +218,7 @@ function ArenaManager:reqArenaInfo(showUI) return end self.isResetting = true - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPInfoReq, {showUI = showUI}, {}, self.rspArenaInfo, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPInfoReq, {showUI = showUI}, self.rspArenaInfo, nil) end function ArenaManager:rspArenaInfo(result) @@ -233,7 +233,7 @@ end -- 结束匹配cd function ArenaManager:reqOverCD(isAd) - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPOverCDReq, {ad = isAd}, {}, self.rspOverCD, BIReport.ITEM_GET_TYPE.ARENA_REMATCH_CD) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPOverCDReq, {ad = isAd}, self.rspOverCD, BIReport.ITEM_GET_TYPE.ARENA_REMATCH_CD) end function ArenaManager:rspOverCD(result) @@ -245,7 +245,7 @@ end -- 领取广告宝箱 function ArenaManager:reqAdBoxReward(isWin) - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPSettlementADRewardReq, {win = isWin}, {}, self.rspAdBoxReward, BIReport.ITEM_GET_TYPE.ARENA_AD_BOX_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPSettlementADRewardReq, {win = isWin}, self.rspAdBoxReward, BIReport.ITEM_GET_TYPE.ARENA_AD_BOX_REWARD) end function ArenaManager:rspAdBoxReward(result) @@ -265,7 +265,7 @@ end function ArenaManager:reqGradingReward(id) local getIds = {} table.insert(getIds, id) - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPStageRewardReq, {ids = getIds}, {}, self.rspGradingReward, BIReport.ITEM_GET_TYPE.ARENA_GRADING_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPStageRewardReq, {ids = getIds}, self.rspGradingReward, BIReport.ITEM_GET_TYPE.ARENA_GRADING_REWARD) end function ArenaManager:rspGradingReward(result) diff --git a/lua/app/module/base_module.lua b/lua/app/module/base_module.lua index 270b1017..6ed752bf 100644 --- a/lua/app/module/base_module.lua +++ b/lua/app/module/base_module.lua @@ -73,11 +73,11 @@ function BaseModule:removeAllEventListeners() end -- 阻塞式,等待服务器回复以后再回调callback -function BaseModule:sendMessage(msgName, params, responseData, callback, getType, lockGame) +function BaseModule:sendMessage(msgName, params, callback, getType, lockGame) if lockGame == nil then lockGame = true end - NetManager:send(self, msgName, params, responseData, callback, lockGame, nil, getType) + NetManager:send(self, msgName, params, callback, lockGame, nil, getType) end -- 阻塞式,等待所有指令完成以后再发送此消息,并且锁界面,等待服务器回复以后再回调callback diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index b029a9f8..0852241f 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -104,7 +104,7 @@ function BattleManager:reqSkillRefresh(isAd) end end - self:sendMessage(ProtoMsgType.FromMsgEnum.BattleSkillRefreshReq, {ad = isAd}, {}, self.rspSkillRefresh, BIReport.ITEM_GET_TYPE.BATTLE_SKILL_REFRESH, true) + self:sendMessage(ProtoMsgType.FromMsgEnum.BattleSkillRefreshReq, {ad = isAd}, self.rspSkillRefresh, BIReport.ITEM_GET_TYPE.BATTLE_SKILL_REFRESH, true) end function BattleManager:rspSkillRefresh(result) diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index 30d5d94f..8791a0ff 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -7,7 +7,7 @@ function ChapterManager:openBox(chapterId, index) local parmas = {} parmas.boxes = DataManager.ChapterData:getChapterBoxCanGetInfo() - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterBoxRewardReq, parmas, {}, self.openBoxFinish, BIReport.ITEM_GET_TYPE.CHAPTER_BOX) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterBoxRewardReq, parmas, self.openBoxFinish, BIReport.ITEM_GET_TYPE.CHAPTER_BOX) end function ChapterManager:openBoxFinish(result) @@ -46,7 +46,7 @@ function ChapterManager:startFight(isTrail) return end end - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterStartReq, parmas, {}, self.startFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterStartReq, parmas, self.startFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START) end function ChapterManager:startFightFinish(result) @@ -96,7 +96,7 @@ function ChapterManager:endFight(id, combatReport, gotMysteryBoxIndexs, taskProg combatReport = combatReport, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterSettlementReq, parmas, {}, self.endFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_END) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterSettlementReq, parmas, self.endFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_END) end function ChapterManager:endFightFinish(result) diff --git a/lua/app/module/collection/collection_manager.lua b/lua/app/module/collection/collection_manager.lua index a69d6e3b..326a69ef 100644 --- a/lua/app/module/collection/collection_manager.lua +++ b/lua/app/module/collection/collection_manager.lua @@ -2,7 +2,7 @@ local CollectionManager = class("CollectionManager", BaseModule) -- 请求领取英雄图鉴点数 function CollectionManager:reqHeroPoint(id) - self:sendMessage(ProtoMsgType.FromMsgEnum.HeroCollectionPointReq, {hero_id = id}, {}, self.rspHeroPoint) + self:sendMessage(ProtoMsgType.FromMsgEnum.HeroCollectionPointReq, {hero_id = id}, self.rspHeroPoint) end function CollectionManager:rspHeroPoint(result) @@ -14,7 +14,7 @@ end -- 请求领取皮肤图鉴点数 function CollectionManager:reqSkinPoint(id) - self:sendMessage(ProtoMsgType.FromMsgEnum.SkinCollectionPointReq, {skin_id = id}, {}, self.rspSkinPoint) + self:sendMessage(ProtoMsgType.FromMsgEnum.SkinCollectionPointReq, {skin_id = id}, self.rspSkinPoint) end function CollectionManager:rspSkinPoint(result) @@ -26,7 +26,7 @@ end -- 请求领取图鉴奖励 function CollectionManager:reqPointReward() - self:sendMessage(ProtoMsgType.FromMsgEnum.CollectionUpgradeReq, {}, {}, self.rspPointReward, BIReport.ITEM_GET_TYPE.COLLECTION_HERO_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.CollectionUpgradeReq, {}, self.rspPointReward, BIReport.ITEM_GET_TYPE.COLLECTION_HERO_REWARD) end function CollectionManager:rspPointReward(result) diff --git a/lua/app/module/commerce/commerce_manager.lua b/lua/app/module/commerce/commerce_manager.lua index b8772143..866bc4f7 100644 --- a/lua/app/module/commerce/commerce_manager.lua +++ b/lua/app/module/commerce/commerce_manager.lua @@ -14,15 +14,9 @@ function CommerceManager:onBuyVit(isFree) } } if isFree then - local reward = ConfigManager:getConfig("const")["stamina_ad_buy"].reward - responseData.rewards = {reward} - self:sendMessage(ProtoMsgType.FromMsgEnum.EnergyByADReq, {}, responseData, self.onBuyBitFinish, BIReport.ITEM_GET_TYPE.ADS_BUY_VIT) + self:sendMessage(ProtoMsgType.FromMsgEnum.EnergyByADReq, {}, self.onBuyBitFinish, BIReport.ITEM_GET_TYPE.ADS_BUY_VIT) else - local reward = ConfigManager:getConfig("const")["stamina_diamond_buy"].reward - responseData.rewards = {reward} - local cost = ConfigManager:getConfig("const")["stamina_diamond_cost"].reward - responseData.costs = {cost} - self:sendMessage(ProtoMsgType.FromMsgEnum.EnergyByDiamondReq, {}, responseData, self.onBuyBitFinish, BIReport.ITEM_GET_TYPE.GEM_BUY_VIT) + self:sendMessage(ProtoMsgType.FromMsgEnum.EnergyByDiamondReq, {}, self.onBuyBitFinish, BIReport.ITEM_GET_TYPE.GEM_BUY_VIT) end end @@ -53,7 +47,7 @@ function CommerceManager:onBuyArenaTicket(isAd) else report = BIReport.ITEM_GET_TYPE.GEM_BUY_ARENA_TICKET end - self:sendMessage(ProtoMsgType.FromMsgEnum.BuyTicketReq, {ad = isAd}, {}, self.onBuyArenaTicketFinish, report) + self:sendMessage(ProtoMsgType.FromMsgEnum.BuyTicketReq, {ad = isAd}, self.onBuyArenaTicketFinish, report) end function CommerceManager:onBuyArenaTicketFinish(data) diff --git a/lua/app/module/daily_challenge/daily_challenge_manager.lua b/lua/app/module/daily_challenge/daily_challenge_manager.lua index bfd081d2..ad73872e 100644 --- a/lua/app/module/daily_challenge/daily_challenge_manager.lua +++ b/lua/app/module/daily_challenge/daily_challenge_manager.lua @@ -65,7 +65,7 @@ function DailyChallengeManager:startChallenge() end local parmas = {} - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE) end function DailyChallengeManager:rspStartChallenge(result) @@ -87,7 +87,7 @@ function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgres taskCurProgress = taskCurProgress } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeSettlementReq, parmas, {}, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeSettlementReq, parmas, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END) end function DailyChallengeManager:endChallengeFinish(result) @@ -142,7 +142,7 @@ function DailyChallengeManager:onResetState() return end DataManager.DailyChallengeData:setInReset(true) - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, {}, {}, self.rspResetState, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, {}, self.rspResetState, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET) end function DailyChallengeManager:rspResetState(result) @@ -156,7 +156,7 @@ function DailyChallengeManager:getTaskReward(idx) local parmas = { idx = idx, } - self:sendMessage(ProtoMsgType.FromMsgEnum.DailyChallengeTaskAwardReq, parmas, {}, self.getTaskRewardFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_TASK_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.DailyChallengeTaskAwardReq, parmas, self.getTaskRewardFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_TASK_REWARD) end function DailyChallengeManager:getTaskRewardFinish(result) @@ -239,7 +239,7 @@ function DailyChallengeManager:onChapterDailyChallengeLevelReq(level) local parmas = { level = level, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeLevelReq, parmas, {}, self.onChapterDailyChallengeLevelRsp) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeLevelReq, parmas, self.onChapterDailyChallengeLevelRsp) end function DailyChallengeManager:onChapterDailyChallengeLevelRsp(result) diff --git a/lua/app/module/dungeon/dungeon_manager.lua b/lua/app/module/dungeon/dungeon_manager.lua index 139c628f..aeff224c 100644 --- a/lua/app/module/dungeon/dungeon_manager.lua +++ b/lua/app/module/dungeon/dungeon_manager.lua @@ -64,7 +64,7 @@ function DungeonManager:reqChallengeGold(id) end local parmas = {chapter_gold_id = id} - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeStartReq, parmas, {}, self.respChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_CHALLENGE) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeStartReq, parmas, self.respChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_CHALLENGE) end -- 响应挑战金币副本 @@ -87,7 +87,7 @@ function DungeonManager:reqEndChallengeGold(id, combatReport, taskProgress, tota task_stat = taskProgress, combatReport = combatReport, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeSettlementReq, parmas, {}, self.respEndChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_END) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeSettlementReq, parmas, self.respEndChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_END) end -- 响应结算金币副本 @@ -138,7 +138,7 @@ function DungeonManager:reqSweepGold(id) local parmas = { chapter_gold_id = id, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeFarmReq, parmas, {}, self.respSweepGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_SWEEP) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeFarmReq, parmas, self.respSweepGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_SWEEP) end -- 响应扫荡金币副本 @@ -171,7 +171,7 @@ function DungeonManager:reqChallengeShards(id) end local parmas = {chapter_shards_id = id} - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeStartReq, parmas, {}, self.respChallengeShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_CHALLENGE) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeStartReq, parmas, self.respChallengeShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_CHALLENGE) end -- 响应挑战碎片副本 @@ -193,7 +193,7 @@ function DungeonManager:reqEndChallengeShards(id, combatReport, taskProgress, to task_stat = taskProgress, combatReport = combatReport, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeSettlementReq, parmas, {}, self.respEndChallengeShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_END) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeSettlementReq, parmas, self.respEndChallengeShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_END) end -- 响应结算碎片副本 @@ -245,7 +245,7 @@ function DungeonManager:reqSweepShards(id) local parmas = { chapter_shards_id = id, } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeFarmReq, parmas, {}, self.respSweepShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_SWEEP) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeFarmReq, parmas, self.respSweepShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_SWEEP) end -- 响应扫荡碎片副本 diff --git a/lua/app/module/equip/equip_manager.lua b/lua/app/module/equip/equip_manager.lua index 7e3264b7..6020d4c5 100644 --- a/lua/app/module/equip/equip_manager.lua +++ b/lua/app/module/equip/equip_manager.lua @@ -45,7 +45,7 @@ function EquipManager:onEquipWearReq(slotId, ids) local params = {} params.slot = slotId params.ids = ids - self:sendMessage(ProtoMsgType.FromMsgEnum.EquipWearReq, params, {}, self.onEquipWearRsp, BIReport.ITEM_GET_TYPE.EQUIP_WEAR) + self:sendMessage(ProtoMsgType.FromMsgEnum.EquipWearReq, params, self.onEquipWearRsp, BIReport.ITEM_GET_TYPE.EQUIP_WEAR) end function EquipManager:onEquipWearRsp(result) @@ -72,7 +72,7 @@ function EquipManager:onEquipUpgradeReq(slotId, part) local params = {} params.slot = slotId params.part = part - self:sendMessage(ProtoMsgType.FromMsgEnum.EquipUpgradeReq, params, {}, self.onEquipUpgradeRsp, BIReport.ITEM_GET_TYPE.EQUIP_LV_UP) + self:sendMessage(ProtoMsgType.FromMsgEnum.EquipUpgradeReq, params, self.onEquipUpgradeRsp, BIReport.ITEM_GET_TYPE.EQUIP_LV_UP) end function EquipManager:onEquipUpgradeRsp(result) @@ -99,7 +99,7 @@ function EquipManager:onEquipRefineReq(slotId, part) local params = {} params.slot = slotId params.part = part - self:sendMessage(ProtoMsgType.FromMsgEnum.EquipRefineReq, params, {}, self.onEquipRefineRsp, BIReport.ITEM_GET_TYPE.EQUIP_REFINE) + self:sendMessage(ProtoMsgType.FromMsgEnum.EquipRefineReq, params, self.onEquipRefineRsp, BIReport.ITEM_GET_TYPE.EQUIP_REFINE) end function EquipManager:onEquipRefineRsp(result) @@ -118,7 +118,7 @@ end -- 装备分解 function EquipManager:onEquipDecomposeReq(ids) - self:sendMessage(ProtoMsgType.FromMsgEnum.EquipDecomposeReq, {ids = ids}, {}, self.onEquipDecomposeRsp, BIReport.ITEM_GET_TYPE.EQUIP_RESOLVE) + self:sendMessage(ProtoMsgType.FromMsgEnum.EquipDecomposeReq, {ids = ids}, self.onEquipDecomposeRsp, BIReport.ITEM_GET_TYPE.EQUIP_RESOLVE) end function EquipManager:onEquipDecomposeRsp(result) diff --git a/lua/app/module/formation/formation_manager.lua b/lua/app/module/formation/formation_manager.lua index 65bcc78c..49bfed19 100644 --- a/lua/app/module/formation/formation_manager.lua +++ b/lua/app/module/formation/formation_manager.lua @@ -6,7 +6,7 @@ function FormationManager:upHeroToStageFormation(heroIds) type = 1, heroes = heroIds } - self:sendMessage(ProtoMsgType.FromMsgEnum.FormationSetReq, args, {}, self.upHeroToStageFormationFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.FormationSetReq, args, self.upHeroToStageFormationFinish) end function FormationManager:upHeroToStageFormationFinish(result) @@ -31,7 +31,7 @@ function FormationManager:reqArenaFormation() attack_heroIds = DataManager.FormationData:getArenaAttackFormation(),-- 进攻编队 defend_heroIds = DataManager.FormationData:getArenaDefendFormation(),-- 防守编队 } - self:sendMessage(ProtoMsgType.FromMsgEnum.PVPHeroesArrayReq, parmas, {}, self.rspArenaFormation, nil) + self:sendMessage(ProtoMsgType.FromMsgEnum.PVPHeroesArrayReq, parmas, self.rspArenaFormation, nil) end function FormationManager:rspArenaFormation(result) diff --git a/lua/app/module/fund/fund_manager.lua b/lua/app/module/fund/fund_manager.lua index a7d72bee..bee3aa32 100644 --- a/lua/app/module/fund/fund_manager.lua +++ b/lua/app/module/fund/fund_manager.lua @@ -58,7 +58,7 @@ function FundManager:claimFundRewards() local args = { id_with_lv = claimRewards } - self:sendMessage(ProtoMsgType.FromMsgEnum.FundAwardReq, args, {}, self.onClaimFundRewards, BIReport.ITEM_GET_TYPE.GROWTH_FUND) + self:sendMessage(ProtoMsgType.FromMsgEnum.FundAwardReq, args, self.onClaimFundRewards, BIReport.ITEM_GET_TYPE.GROWTH_FUND) end function FundManager:onClaimFundRewards(result) diff --git a/lua/app/module/game_setting/game_setting_manager.lua b/lua/app/module/game_setting/game_setting_manager.lua index 12410671..b538e866 100644 --- a/lua/app/module/game_setting/game_setting_manager.lua +++ b/lua/app/module/game_setting/game_setting_manager.lua @@ -24,7 +24,7 @@ function GameSettingManager:exchangeCdkey(key) local args = { key = key } - self:sendMessage(ProtoMsgType.FromMsgEnum.CDKeyUseReq, args, {}, self.onExchangeCdkey, BIReport.ITEM_GET_TYPE.CDKEY) + self:sendMessage(ProtoMsgType.FromMsgEnum.CDKeyUseReq, args, self.onExchangeCdkey, BIReport.ITEM_GET_TYPE.CDKEY) end function GameSettingManager:onExchangeCdkey(result) @@ -83,7 +83,7 @@ function GameSettingManager:showSupport(objectId) end function GameSettingManager:reqAiHelper() - self:sendMessage(ProtoMsgType.FromMsgEnum.AIHelpUnreadReq, {}, {}, self.rspAiHelper) + self:sendMessage(ProtoMsgType.FromMsgEnum.AIHelpUnreadReq, {}, self.rspAiHelper) end function GameSettingManager:rspAiHelper(result) diff --git a/lua/app/module/gm/dev_tool_manager.lua b/lua/app/module/gm/dev_tool_manager.lua index fc12618c..74bc035d 100644 --- a/lua/app/module/gm/dev_tool_manager.lua +++ b/lua/app/module/gm/dev_tool_manager.lua @@ -77,7 +77,7 @@ function DevToolManager:getCacheDemoFightInfo() end function DevToolManager:dealGM(paramsList) - self:sendMessage(ProtoMsgType.FromMsgEnum.GMReq, paramsList, {}, self.onDealGMFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.GMReq, paramsList, self.onDealGMFinish) end function DevToolManager:onDealGMFinish(parmas, code, result) diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index 69886f63..f8facaeb 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -28,7 +28,7 @@ function HeroManager:upgradeHero(heroId, heroEntity, level) return end - self:sendMessage(ProtoMsgType.FromMsgEnum.HeroUpgradeReq, {id = heroId, level = level}, {}, self.upgradeHeroFinish, BIReport.ITEM_GET_TYPE.UPGRADE_HERO) + self:sendMessage(ProtoMsgType.FromMsgEnum.HeroUpgradeReq, {id = heroId, level = level}, self.upgradeHeroFinish, BIReport.ITEM_GET_TYPE.UPGRADE_HERO) end function HeroManager:upgradeHeroFinish(result) @@ -53,7 +53,7 @@ function HeroManager:upgradeHeroStar(heroId, heroEntity) return end - self:sendMessage(ProtoMsgType.FromMsgEnum.HeroStarReq, {id = heroId}, {}, self.heroStarReqFinish, BIReport.ITEM_GET_TYPE.UPGRADE_HERO) + self:sendMessage(ProtoMsgType.FromMsgEnum.HeroStarReq, {id = heroId}, self.heroStarReqFinish, BIReport.ITEM_GET_TYPE.UPGRADE_HERO) end function HeroManager:heroStarReqFinish(result) diff --git a/lua/app/module/idle/idle_manager.lua b/lua/app/module/idle/idle_manager.lua index ff83f4e0..f0fa1a12 100644 --- a/lua/app/module/idle/idle_manager.lua +++ b/lua/app/module/idle/idle_manager.lua @@ -10,7 +10,7 @@ function IdleManager:showIdleQuickDropUI(params) end function IdleManager:getIdleShowRewrad() - self:sendMessage(ProtoMsgType.FromMsgEnum.IdleInfoReq, {}, {}, self.onGetIdleShowRewrad, BIReport.ITEM_GET_TYPE.NONE) + self:sendMessage(ProtoMsgType.FromMsgEnum.IdleInfoReq, {}, self.onGetIdleShowRewrad, BIReport.ITEM_GET_TYPE.NONE) end function IdleManager:onGetIdleShowRewrad(result) @@ -20,7 +20,7 @@ function IdleManager:onGetIdleShowRewrad(result) end function IdleManager:getIdleRewrad() - self:sendMessage(ProtoMsgType.FromMsgEnum.IdleRewardReq, {}, {}, self.onGetIdleRewrad, BIReport.ITEM_GET_TYPE.IDLE_DROP) + self:sendMessage(ProtoMsgType.FromMsgEnum.IdleRewardReq, {}, self.onGetIdleRewrad, BIReport.ITEM_GET_TYPE.IDLE_DROP) end function IdleManager:onGetIdleRewrad(result) @@ -38,7 +38,7 @@ function IdleManager:getIdleQuickRewrad(isAd) local args = { ad = true } - self:sendMessage(ProtoMsgType.FromMsgEnum.IdleQuickReq, args, {}, self.onGetIdleQuickRewrad, BIReport.ITEM_GET_TYPE.IDLE_QUICK_DROP) + self:sendMessage(ProtoMsgType.FromMsgEnum.IdleQuickReq, args, self.onGetIdleQuickRewrad, BIReport.ITEM_GET_TYPE.IDLE_QUICK_DROP) end) else local cost = DataManager.IdleData:getQuickIdleCost()[1] @@ -53,7 +53,7 @@ function IdleManager:getIdleQuickRewrad(isAd) local args = { ad = false } - self:sendMessage(ProtoMsgType.FromMsgEnum.IdleQuickReq, args, {}, self.onGetIdleQuickRewrad, BIReport.ITEM_GET_TYPE.IDLE_QUICK_DROP) + self:sendMessage(ProtoMsgType.FromMsgEnum.IdleQuickReq, args, self.onGetIdleQuickRewrad, BIReport.ITEM_GET_TYPE.IDLE_QUICK_DROP) end end diff --git a/lua/app/module/login/login_manager.lua b/lua/app/module/login/login_manager.lua index 74f3e66d..7bd3b363 100644 --- a/lua/app/module/login/login_manager.lua +++ b/lua/app/module/login/login_manager.lua @@ -140,7 +140,6 @@ function LoginManager:_login() self:sendMessage( ProtoMsgType.FromMsgEnum.LoginReq, args, - {}, self.loginFinish, nil, false ) diff --git a/lua/app/module/mail/mail_manager.lua b/lua/app/module/mail/mail_manager.lua index b3559049..83799156 100644 --- a/lua/app/module/mail/mail_manager.lua +++ b/lua/app/module/mail/mail_manager.lua @@ -15,7 +15,7 @@ function MailManager:getMailList(force) self.needUpdateMailSid = nil end - self:sendMessage(ProtoMsgType.FromMsgEnum.MailListReq, {}, {}, self.getMailListFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.MailListReq, {}, self.getMailListFinish) end function MailManager:getMailListFinish(result) @@ -31,7 +31,7 @@ end -- 触发服务器时间相关邮件 function MailManager:getTriggeredTimeMail() - self:sendMessage(ProtoMsgType.FromMsgEnum.MailCycleReq, {}, {}, self.getTriggeredTimeMailFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.MailCycleReq, {}, self.getTriggeredTimeMailFinish) end function MailManager:getTriggeredTimeMailFinish(result) @@ -62,7 +62,7 @@ function MailManager:claimMail(ids) end local reqData = {ids = ids} - self:sendMessage(ProtoMsgType.FromMsgEnum.MailExtractReq, reqData, {}, self.claimMailFinish, BIReport.ITEM_GET_TYPE.MAIL) + self:sendMessage(ProtoMsgType.FromMsgEnum.MailExtractReq, reqData, self.claimMailFinish, BIReport.ITEM_GET_TYPE.MAIL) end function MailManager:claimMailFinish(result) @@ -104,8 +104,7 @@ function MailManager:deleteMail(ids) return end local reqData = {ids = ids} - local rspData = {ids = ids} - self:sendMessage(ProtoMsgType.FromMsgEnum.MailDeleteReq, reqData, rspData, self.deleteMailFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.MailDeleteReq, reqData, self.deleteMailFinish) end function MailManager:deleteMailFinish(result) @@ -122,8 +121,7 @@ function MailManager:readMail(id) end local reqData = {ids = {id}} - local rspData = {ids = {id}} - self:sendMessage(ProtoMsgType.FromMsgEnum.MailReadReq, reqData, rspData, self.readMailFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.MailReadReq, reqData, self.readMailFinish) end function MailManager:readMailFinish(result) diff --git a/lua/app/module/player/player_manager.lua b/lua/app/module/player/player_manager.lua index 9f200113..6ff79497 100644 --- a/lua/app/module/player/player_manager.lua +++ b/lua/app/module/player/player_manager.lua @@ -16,7 +16,7 @@ function PlayerManager:showPlayerUpUI(currLv, rewards) end function PlayerManager:levelUp() - self:sendMessage(ProtoMsgType.FromMsgEnum.LevelUpReq, {}, {}, self.onLevelUpFinish, BIReport.ITEM_GET_TYPE.PLAYER_LV_UP) + self:sendMessage(ProtoMsgType.FromMsgEnum.LevelUpReq, {}, self.onLevelUpFinish, BIReport.ITEM_GET_TYPE.PLAYER_LV_UP) end function PlayerManager:onLevelUpFinish(result) @@ -35,7 +35,7 @@ end -- 修改昵称 function PlayerManager:reqChangeNickname(changeName) - self:sendMessage(ProtoMsgType.FromMsgEnum.ChangeNameReq, {name = changeName}, {}, self.respChangeNickname, BIReport.ITEM_GET_TYPE.CHANGE_NAME) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChangeNameReq, {name = changeName}, self.respChangeNickname, BIReport.ITEM_GET_TYPE.CHANGE_NAME) end function PlayerManager:respChangeNickname(result) @@ -49,7 +49,7 @@ end -- 修改头像 function PlayerManager:reqChangeAvatar(changeId) - self:sendMessage(ProtoMsgType.FromMsgEnum.ChangeAvatarReq, {id = changeId}, {}, self.respChangeAvatar, BIReport.ITEM_GET_TYPE.CHANGE_AVATAR) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChangeAvatarReq, {id = changeId}, self.respChangeAvatar, BIReport.ITEM_GET_TYPE.CHANGE_AVATAR) end function PlayerManager:respChangeAvatar(result) @@ -60,7 +60,7 @@ end -- 修改头像框 function PlayerManager:reqChangeFrame(changeId) - self:sendMessage(ProtoMsgType.FromMsgEnum.ChangeAvatarFrameReq, {id = changeId}, {}, self.respChangeFrame, BIReport.ITEM_GET_TYPE.CHANGE_FRAME) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChangeAvatarFrameReq, {id = changeId}, self.respChangeFrame, BIReport.ITEM_GET_TYPE.CHANGE_FRAME) end function PlayerManager:respChangeFrame(result) diff --git a/lua/app/module/skin/skin_manager.lua b/lua/app/module/skin/skin_manager.lua index 40f6da21..ac34a9c6 100644 --- a/lua/app/module/skin/skin_manager.lua +++ b/lua/app/module/skin/skin_manager.lua @@ -21,7 +21,7 @@ end -- 使用皮肤 function SkinManager:reqChangeSkin(heroId, skinId) - self:sendMessage(ProtoMsgType.FromMsgEnum.HeroChangeSkinReq, {id = heroId, skin_id = skinId}, {}, self.rspChangeSkin) + self:sendMessage(ProtoMsgType.FromMsgEnum.HeroChangeSkinReq, {id = heroId, skin_id = skinId}, self.rspChangeSkin) end function SkinManager:rspChangeSkin(result) diff --git a/lua/app/module/summon/summon_manager.lua b/lua/app/module/summon/summon_manager.lua index 78d3a730..ee104b37 100644 --- a/lua/app/module/summon/summon_manager.lua +++ b/lua/app/module/summon/summon_manager.lua @@ -37,7 +37,7 @@ function SummonManager:onForceSummonReq(count, free, summonType) args.times = count args.free = free args.id = summonType - self:sendMessage(ProtoMsgType.FromMsgEnum.SummonReq, args, {}, self.onForceSummonRsp, BIReport.ITEM_GET_TYPE.FORCE_SUMMON) + self:sendMessage(ProtoMsgType.FromMsgEnum.SummonReq, args, self.onForceSummonRsp, BIReport.ITEM_GET_TYPE.FORCE_SUMMON) end function SummonManager:onForceSummonRsp(result) @@ -77,7 +77,7 @@ end --@endregion function SummonManager:onSummonWishSetReq(summonType, heroId) - self:sendMessage(ProtoMsgType.FromMsgEnum.SummonWishSetReq, {id = summonType, hero = heroId}, {}, self.onSummonWishSetRsp, + self:sendMessage(ProtoMsgType.FromMsgEnum.SummonWishSetReq, {id = summonType, hero = heroId}, self.onSummonWishSetRsp, BIReport.ITEM_GET_TYPE.FORCE_SUMMON_WISH_HREO_ID) end @@ -90,7 +90,7 @@ function SummonManager:onSummonWishSetRsp(result) end function SummonManager:onSummonWishClaimReq(summonType) - self:sendMessage(ProtoMsgType.FromMsgEnum.SummonWishClaimReq, {id = summonType}, {}, self.onSummonWishClaimRsp, + self:sendMessage(ProtoMsgType.FromMsgEnum.SummonWishClaimReq, {id = summonType}, self.onSummonWishClaimRsp, BIReport.ITEM_GET_TYPE.FORCE_SUMMON_WISH_HREO_ID) end diff --git a/lua/app/module/talent/talent_manager.lua b/lua/app/module/talent/talent_manager.lua index bbccda87..9fc0116a 100644 --- a/lua/app/module/talent/talent_manager.lua +++ b/lua/app/module/talent/talent_manager.lua @@ -10,7 +10,7 @@ end function TalentManager:talentUpgrade() local args = {} - self:sendMessage(ProtoMsgType.FromMsgEnum.TalentUpgradeReq, args, {}, self.onTalentUpgradeRsp, BIReport.ITEM_GET_TYPE.BOUNTY_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.TalentUpgradeReq, args, self.onTalentUpgradeRsp, BIReport.ITEM_GET_TYPE.BOUNTY_REWARD) end function TalentManager:onTalentUpgradeRsp(result) diff --git a/lua/app/module/task/task_manager.lua b/lua/app/module/task/task_manager.lua index 269ea535..60fe26db 100644 --- a/lua/app/module/task/task_manager.lua +++ b/lua/app/module/task/task_manager.lua @@ -20,7 +20,7 @@ function TaskManager:onTaskDailyStageRewardReq(dailyTaskId) local parmas = {} parmas.id = 0 -- parmas.type = 1 - self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyStageRewardReq, parmas, {}, self.onTaskDailyStageRewardRsp, BIReport.ITEM_GET_TYPE.TASK_DAILY_REFRESH) + self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyStageRewardReq, parmas, self.onTaskDailyStageRewardRsp, BIReport.ITEM_GET_TYPE.TASK_DAILY_REFRESH) end function TaskManager:onTaskDailyStageRewardRsp(result) @@ -40,7 +40,7 @@ function TaskManager:claimDailyTask(dailyTaskId) -- id = dailyTaskId, id = 0, } - self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyRewardReq, parmas, {}, self.onDailyTaskClaim, BIReport.ITEM_GET_TYPE.TASK_DAILY_REWARD) + self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyRewardReq, parmas, self.onDailyTaskClaim, BIReport.ITEM_GET_TYPE.TASK_DAILY_REWARD) end function TaskManager:onDailyTaskClaim(result) @@ -60,7 +60,7 @@ function TaskManager:resetDailyTask() return end DataManager.DailyTaskData:setInReset(true) - self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyInfoReq, {}, {}, self.onResetDailyTask, BIReport.ITEM_GET_TYPE.NONE) + self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyInfoReq, {}, self.onResetDailyTask, BIReport.ITEM_GET_TYPE.NONE) end function TaskManager:onResetDailyTask(result) @@ -72,7 +72,7 @@ end function TaskManager:watchTaskSpecialAd() SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.TASK_DAILY_TASK, function() - self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyAdReq, {}, {}, self.onWatchTaskSpecialAd, BIReport.ITEM_GET_TYPE.NONE) + self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyAdReq, {}, self.onWatchTaskSpecialAd, BIReport.ITEM_GET_TYPE.NONE) end) end @@ -156,7 +156,7 @@ function TaskManager:onTaskAchievementReq(taskId, stage) -- 一键领取处理 taskId = nil stage = nil - self:sendMessage(ProtoMsgType.FromMsgEnum.TaskAchievementReq, {task_id = taskId, stage = stage}, {}, self.onTaskAchievementRsp, BIReport.ITEM_GET_TYPE.TASK_ACHIEVEMENT) + self:sendMessage(ProtoMsgType.FromMsgEnum.TaskAchievementReq, {task_id = taskId, stage = stage}, self.onTaskAchievementRsp, BIReport.ITEM_GET_TYPE.TASK_ACHIEVEMENT) end function TaskManager:onTaskAchievementRsp(result) diff --git a/lua/app/module/tutorial/tutorial_manager.lua b/lua/app/module/tutorial/tutorial_manager.lua index bb63c616..e152cd82 100644 --- a/lua/app/module/tutorial/tutorial_manager.lua +++ b/lua/app/module/tutorial/tutorial_manager.lua @@ -23,7 +23,7 @@ function TutorialManager:sendTutorialId(id, callback) self.sendTutorialIdCallback = callback - self:sendMessage(ProtoMsgType.FromMsgEnum.GuideFundMarkReq, args, {}, self.sendTutorialIdFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.GuideFundMarkReq, args, self.sendTutorialIdFinish) end function TutorialManager:sendTutorialIdFinish(result) diff --git a/lua/app/net/net_manager.lua b/lua/app/net/net_manager.lua index 229bca7e..9888a01f 100644 --- a/lua/app/net/net_manager.lua +++ b/lua/app/net/net_manager.lua @@ -8,15 +8,16 @@ local NetManager = receiveCallbackPool = {}, alreadyConnected = {}, mainReconnectWaitTime = 0, - sendQueue = {}, + sendQueue = {}, tillBeforeOverCount = 0, - msgId = 0 + msgId = 0, + lastReceiveTime = 0 } local CSApplication = CS.UnityEngine.Application local CSNotReachable = CS.UnityEngine.NetworkReachability.NotReachable -local MAX_CHAT_WAIT_TIME = 16 +local MAX_CHAT_WAIT_TIME = 64 local MAX_MAIN_WAIT_TIME = 10 local JOIN_CHAT_INTERVAL = 15 local TILL_BEFORE_INTERVAL = 0.5 @@ -34,25 +35,27 @@ local protoPaths = NetManager.MAIN_SOCKET_NAME = 0 NetManager.CHAT_SOCKET_NAME = 1 NetManager.LOGIN_TYPE = { - TOKEN = "token", - ANONYMOUS = "anonymous", - GOOGLE = "google", - APPLE = "apple", + TOKEN = "token", + ANONYMOUS = "anonymous", + GOOGLE = "google", + APPLE = "apple", FACEBOOK = "facebook", + FACEBOOK_LIMITED = "facebook_limited", + VKID = "vk", } function NetManager:getGate() - if EDITOR_MODE then - return "https://entrance.wdd817.link" - else - return "https://d3ksek7t8d0wbt.cloudfront.net/" - end + if EDITOR_MODE then + return "http://game.juzugame.com:3000" + else + return "https://d3ksek7t8d0wbt.cloudfront.net/" + end end function NetManager:init(callback) self.chatReconnectWaitTime = 1 - CS.BF.BFMain.Instance.NetMgr:InitNetClientCount(1) -- 只有主链接,没有聊天,但是聊天逻辑先不删 + CS.BF.BFMain.Instance.NetMgr:InitNetClientCount(2) if self.initSucc then if callback then return callback() @@ -79,7 +82,7 @@ end function NetManager:setChatUrl(url) local arr = string.split(url, ":") self.chatDomain = arr[1] - self.chatPort = arr[2] + self.chatPort = arr[2] end function NetManager:getChatDomain() @@ -95,7 +98,7 @@ function NetManager:getIsBusy() end function NetManager:isNotReachable() - return CSApplication.internetReachability == CSNotReachable + return CSApplication.internetReachability == CSNotReachable end function NetManager:connect(domain, port, callback, socketName) @@ -112,6 +115,7 @@ function NetManager:connect(domain, port, callback, socketName) if socketName == NetManager.MAIN_SOCKET_NAME then UIManager:showWaitNet(true) + self.alreadyClose = false end self.connectIPMap[socketName] = "" @@ -137,7 +141,6 @@ function NetManager:connect(domain, port, callback, socketName) if DataManager.ChatData then DataManager.ChatData:onConnect() end - self:joinChatChannel() end if callback then callback() @@ -145,18 +148,19 @@ function NetManager:connect(domain, port, callback, socketName) end) CS.BF.BFMain.Instance.NetMgr:AddLuaOnDisconnected(function(name) - -- self:onDisconnect(name) - self:disconnectAndReconnect() + Logger.log("[NetManager]disconnected:%s", name) + self:onDisconnect(name) end) CS.BF.BFMain.Instance.NetMgr:AddLuaOnReceiveMessage(function(name, group, recvId, bytes) if name == NetManager.MAIN_SOCKET_NAME then + self.lastReceiveTime = Time:getServerTime() self.recvId = recvId if self.reconnectMainFlag then -- 如果是在重连状态下收到消息就设置下重连所需要的数据 self:setReconnectData() end end - self:onReceive(group, bytes) + self:onReceive(group, bytes, name) end) CS.BF.BFMain.Instance.NetMgr:AddLuaOnError(function(name, errorCode, errorMsg) @@ -165,14 +169,21 @@ function NetManager:connect(domain, port, callback, socketName) CS.BF.BFMain.Instance.NetMgr:AddLuaOnReconnectSuccess(function(name) Logger.log("[NetManager]reconnect succes:%s", name) - if self.receiveCallbacks["ChapterSettlementRsp"] then -- 处理一下重发问题 - if #self.receiveCallbacks["ChapterSettlementRsp"] > 0 then - self.receiveCallbacks["ChapterSettlementRsp"] = nil - self.isSending = false + + + if name == NetManager.MAIN_SOCKET_NAME then + local count = 0 + for msg, list in pairs(self.receiveCallbacks) do + for k, v in ipairs(list) do + if v.socketName == NetManager.MAIN_SOCKET_NAME then + count = 1 + break + end + end + end + if count <= 0 then -- 没有正在等待回复的消息,检测如果有断线时的缓存消息,则直接发送 self:trySend() end - end - if name == NetManager.MAIN_SOCKET_NAME then if self.reconnectMainId then SchedulerManager:unscheduleGlobal(self.reconnectMainId) self.reconnectMainId = nil @@ -193,7 +204,7 @@ function NetManager:connect(domain, port, callback, socketName) durationTime = Time:getServerTime() - self.disconnectTime self.disconnectTime = nil end - BIReport:postNetWorkOpt(BIReport.NETWORK_OPT_TYPE.RECONNECT, UIManager:getTopUIIndex(), nil, durationTime) + BIReport:postNetWorkOpt(BIReport.NETWORK_OPT_TYPE.RECONNECT, UIManager:getTopUIIndex(), nil, nil,durationTime) else self.chatReconnectWaitTime = 1 if self.reconnectChatId then @@ -207,7 +218,6 @@ function NetManager:connect(domain, port, callback, socketName) if DataManager.ChatData then DataManager.ChatData:onConnect() end - self:joinChatChannel() end end) @@ -224,90 +234,121 @@ function NetManager:connect(domain, port, callback, socketName) return pb.decode(fullMsgName, data) end) - 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() - return - end - - if msgName == "ReconnectRsp" then -- Reconnect失败就直接回登录界面 - self:closeAll() - else - self:closeAndClear() - local accountInfo = LocalData:getAccountInfo() - local loginType - local lastLoginType - if accountInfo.google_id and accountInfo.google_id ~= "" then - loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE - lastLoginType = NetManager.LOGIN_TYPE.GOOGLE - elseif accountInfo.apple_id and accountInfo.apple_id ~= "" then - loginType = SDKManager.BF_LOGIN_TYPE.APPLE - lastLoginType = NetManager.LOGIN_TYPE.APPLE + if name == NetManager.MAIN_SOCKET_NAME then + if ok and pbData then + pbData.status = not pbData.err_code and 0 or ProtoMsgDispatch:getErrCodeEnum(pbData.err_code) + if pbData.status ~= 0 then + if pbData.err_code == GConst.ERROR_STR.COUNTRY_NOT_ALLOWED then -- ip限制 + local taData = { + ip_limit = true + } + BIReport:TAUserSet(taData) + BIReport:postIpLimit() end - if loginType then - SDKManager:login(function(params) - if not params.token then - return - end - LocalData:setLastLoginInfo(lastLoginType, params.id, params.token) - ModuleManager.LoginManager:saveAuthArgs(false) - ModuleManager.LoginManager:initSocket() - end, loginType) + + 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() + return + end + + if msgName == "ReconnectRsp" then -- Reconnect失败就直接回登录界面 + self:closeAll() else - if not self.autoReAuth then - self.autoReAuth = true - self.autoReAuthSid = self:performWithDelayGlobal(function() + self:closeAndClear() + local accountInfo = LocalData:getAccountInfo() + local loginType + local lastLoginType + if accountInfo.google_id and accountInfo.google_id ~= "" then + loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE + lastLoginType = NetManager.LOGIN_TYPE.GOOGLE + elseif accountInfo.apple_id and accountInfo.apple_id ~= "" then + loginType = SDKManager.BF_LOGIN_TYPE.APPLE + lastLoginType = NetManager.LOGIN_TYPE.APPLE + elseif accountInfo.facebook_id and accountInfo.facebook_id ~= "" then + loginType = SDKManager.BF_LOGIN_TYPE.FACEBOOK + lastLoginType = SDKManager:getLoginTypeFacebook() + elseif accountInfo.vk_id and accountInfo.vk_id ~= "" then + loginType = SDKManager.BF_LOGIN_TYPE.VKID + lastLoginType = NetManager.LOGIN_TYPE.VKID + end + if loginType then + SDKManager:login(function(params) + if not params.token then + return + end + LocalData:setLastLoginInfo(lastLoginType, params.id, params.token) + ModuleManager.LoginManager:saveAuthArgs(false) ModuleManager.LoginManager:initSocket() - end, 0.5) + 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() - self.autoReAuth = false + 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_DESC_1), + 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) + + if pbData.id then -- 重连也会走到这儿,但是没有token等信息 + LocalData:setLastLoginInfo(NetManager.LOGIN_TYPE.TOKEN, pbData.id, pbData.token) + LocalData:setAccountInfo(pbData) + DataManager.PlayerData:setAuthInfo(pbData) + DataManager:setAuthInfo(pbData) + end + + pbData.send_id = pbData.send_id or 0 + pbData.err_code = nil + CS.BF.BFMain.Instance.NetMgr.decodePbStr = json.encode(pbData) + CS.BF.BFMain.Instance.NetMgr.rspGroup = group + CS.BF.BFMain.Instance.NetMgr.decodeFinish = true + end + end + else + if ok and pbData then + pbData.status = not pbData.err_code and 0 or ProtoMsgDispatch:getErrCodeEnum(pbData.err_code) + if pbData.status == 0 then + CS.BF.BFMain.Instance.NetMgr.decodeChatPbStr = json.encode(pbData) + CS.BF.BFMain.Instance.NetMgr.rspChatGroup = group + CS.BF.BFMain.Instance.NetMgr.decodeChatFinish = true + self:joinChatChannel() + else + self:disconnect(name) 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) - - if pbData.id then -- 重连也会走到这儿,但是没有token等信息 - LocalData:setLastLoginInfo(NetManager.LOGIN_TYPE.TOKEN, pbData.id, pbData.token) - LocalData:setAccountInfo(pbData) - BIReport:updateAccountId(pbData.id) - end - - pbData.send_id = pbData.send_id or 0 - pbData.err_code = nil - CS.BF.BFMain.Instance.NetMgr.decodePbStr = json.encode(pbData) - CS.BF.BFMain.Instance.NetMgr.rspGroup = group - CS.BF.BFMain.Instance.NetMgr.decodeFinish = true + self:disconnect(name) end end end) @@ -315,7 +356,7 @@ function NetManager:connect(domain, port, callback, socketName) CS.BF.BFMain.Instance.NetMgr:SetLuaAuthCallback(function(isSuccess) if not isSuccess then local params = { - content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_RELOGIN), + content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_DESC_1), okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), noShowClose = true, okFunc = function() @@ -333,16 +374,16 @@ function NetManager:connect(domain, port, callback, socketName) configuration:EnableMessageType(CS.BF.NetIncomingMessageType.WarningMessage) configuration:EnableMessageType(CS.BF.NetIncomingMessageType.ErrorMessage) if socketName == NetManager.MAIN_SOCKET_NAME then - configuration.EnableSilenceReconnect = false -- game连接不用自动重连 - configuration.ReconnectTimeoutTime = GConst.WAIT_NET_RSP_TIME -- 每次重连超时时间 + configuration.EnableSilenceReconnect = false -- game连接不用自动重连 + configuration.ReconnectTimeoutTime = GConst.WAIT_NET_RSP_TIME -- 每次重连超时时间 configuration.AlreadySendMessageCacheCount = 3 else - -- configuration.ReconnectTimeoutTime = 8 -- 每次重连超时时间 - -- configuration.ReconnectBaseInterval = 1 -- 每次重连间隔时间 - -- configuration.AutoReconnectCount = 5 -- 重连次数 + -- configuration.ReconnectTimeoutTime = 8 -- 每次重连超时时间 + -- configuration.ReconnectBaseInterval = 1 -- 每次重连间隔时间 + -- configuration.AutoReconnectCount = 5 -- 重连次数 -- 自动重连可能有bug,先手动重连 - configuration.EnableSilenceReconnect = false -- chat连接不用自动重连 - configuration.ReconnectTimeoutTime = MAX_CHAT_WAIT_TIME -- 每次重连超时时间 + configuration.EnableSilenceReconnect = false -- chat连接不用自动重连 + configuration.ReconnectTimeoutTime = MAX_CHAT_WAIT_TIME -- 每次重连超时时间 configuration.AlreadySendMessageCacheCount = 3 end CS.BF.BFMain.Instance.NetMgr:ConnectWithConfiguration(socketName, configuration, domain, tonumber(port)) @@ -376,8 +417,12 @@ function NetManager:getConnectIP(socketName) return CS.BF.BFMain.Instance.NetMgr:GetConnectIP(socketName) end -function NetManager:_sendBytes(clientName, bytes, group, cmd) - self.isSending = true +function NetManager:_sendBytes(clientName, bytes, group, cmd, noRsp) + if clientName ~= NetManager.CHAT_SOCKET_NAME then + if not noRsp then + self.isSending = true + end + end CS.BF.BFMain.Instance.NetMgr:Send(clientName, group, cmd, bytes) end @@ -400,37 +445,82 @@ end function NetManager:saveChatAuthArgs(token) local msgFullName = ProtoMsgDispatch:getMsgFullNameByMsgName(ProtoMsgType.FromMsgEnum.ChatAuthReq) local args = { - id = DataManager.PlayerData:getUid(), + id = DataManager.PlayerData:getPlayerId(), token = token } CS.BF.BFMain.Instance.NetMgr.ChatAuthReqData = pb.encode(msgFullName, args) end -function NetManager:send(binder, msgName, params, responseData, callback, lockGame, noRsp, getType) - if responseData.rewards then - responseData.rewards = GFunc.formatRewardsToServerStruct(responseData.rewards) +function NetManager:sendChat(binder, msgName, params, callback) + if self.alreadyClose then + return end - if responseData.costs then - responseData.costs = GFunc.formatRewardsToServerStruct(responseData.costs) + local socketName = NetManager.CHAT_SOCKET_NAME + if self:isDisconnected(socketName) then + self:disconnect(socketName) + return end - responseData.err_code = GConst.ERROR_STR.SUCCESS - self:_send(binder, msgName, params, responseData, callback, lockGame, noRsp, getType) + Logger.log("===onSendChat===:%s", msgName) + local msgFullName = ProtoMsgDispatch:getMsgFullNameByMsgName(msgName) + local bytes = pb.encode(msgFullName, params) + if bytes == nil then + Logger.logError("SocketManager send data error %s", msgName) + return callback and callback() + end + + local msgId = ProtoMsgDispatch:getMsgIdByMsgName(msgName) + self:_sendBytes(socketName, bytes, msgId, 0) + + local msg = ProtoMsgDispatch:getRspMsgByMsgName(msgName) + if not self.receiveCallbacks[msg] then + self.receiveCallbacks[msg] = {} + end + local receiveCallback = self:getReceiveCallback() + receiveCallback.binder = binder + receiveCallback.lockGame = false + receiveCallback.callback = callback + receiveCallback.getType = BIReport.ITEM_GET_TYPE.NONE + receiveCallback.beforeOver = false + receiveCallback.socketName = NetManager.CHAT_SOCKET_NAME + receiveCallback.reqData = params + table.insert(self.receiveCallbacks[msg], receiveCallback) end -function NetManager:sendTillBeforeOver(binder, msgName, params, responseData, callback, lockGame, noRsp, getType) - if responseData.rewards then - responseData.rewards = GFunc.formatRewardsToServerStruct(responseData.rewards) +function NetManager:send(binder, msgName, params, callback, lockGame, noRsp, getType) + if self.alreadyClose then + return end - if responseData.costs then - responseData.costs = GFunc.formatRewardsToServerStruct(responseData.costs) - end - responseData.err_code = GConst.ERROR_STR.SUCCESS - self:_send(binder, msgName, params, responseData, callback, lockGame, noRsp, getType, true) + self:_send(binder, msgName, params, callback, lockGame, noRsp, getType) end -function NetManager:_send(binder, msgName, params, responseData, callback, lockGame, noRsp, getType, beforeOver) +function NetManager:sendTillBeforeOver(binder, msgName, params, callback, lockGame, noRsp, getType) + if self.alreadyClose then + return + end + self:_send(binder, msgName, params, callback, lockGame, noRsp, getType, true) +end + +function NetManager:_send(binder, msgName, params, callback, lockGame, noRsp, getType, beforeOver) local socketName = NetManager.MAIN_SOCKET_NAME - if self:isDisconnected(socketName) then + local pipedMsgName, pipedParams = self:pipedMessage(msgName, params) + table.insert(self.sendQueue, { + binder = binder, + originMsgName = msgName, + msgName = pipedMsgName, + params = pipedParams, + socketName = socketName, + callback = callback, + lockGame = lockGame, + noRsp = noRsp, + getType = getType, + beforeOver = beforeOver, + }) + + if not self:isNotSave(msgName) then + self:saveSendQueue() + end + + if self:isDisconnected(socketName) then if socketName == NetManager.MAIN_SOCKET_NAME then if UIManager:getWaitNetCount() > 0 then self:disconnect(socketName) @@ -444,74 +534,56 @@ function NetManager:_send(binder, msgName, params, responseData, callback, lockG else self:disconnect(socketName) end - else + else if beforeOver then UIManager:showWaitNet() self.tillBeforeOverCount = self.tillBeforeOverCount + 1 end - local pipedMsgName, pipedParams = self:pipedMessage(msgName, params) - table.insert(self.sendQueue, { - binder = binder, - originMsgName = msgName, - msgName = pipedMsgName, - params = pipedParams, - responseData = responseData, - socketName = socketName, - callback = callback, - lockGame = lockGame, - noRsp = noRsp, - getType = getType, - beforeOver = beforeOver, - }) - if not self:isNotSave(msgName) then - self:saveSendQueue() - end - self:trySend() - end + self:trySend() + end end function NetManager:trySend() local binder local originMsgName - local curMsgName - local curParams - local responseData + local curMsgName + local curParams local getType - local curSocketName - local curCallback - local curLockGame - local noRsp + local curSocketName + local curCallback + local curLockGame + local noRsp local beforeOver - if not self.isSending and self.sendQueue[1] then -- 没有正在发送的消息,并且有发送队列, 则继续发送 - local cache = self.sendQueue[1] + if not self.isSending and self.sendQueue[1] then -- 没有正在发送的消息,并且有发送队列, 则继续发送 + local cache = self.sendQueue[1] binder = cache.binder originMsgName = cache.originMsgName - curMsgName = cache.msgName - curParams = GFunc.getTable(cache.params) - responseData = cache.responseData + curMsgName = cache.msgName + curParams = GFunc.getTable(cache.params) getType = cache.getType - curSocketName = cache.socketName - curCallback = cache.callback - curLockGame = cache.lockGame - noRsp = cache.noRsp + curSocketName = cache.socketName + curCallback = cache.callback + curLockGame = cache.lockGame + noRsp = cache.noRsp beforeOver = cache.beforeOver - end + end - if curMsgName then + if curMsgName then if EDITOR_MODE then local subName = curMsgName local reqData if curMsgName == ProtoMsgType.FromMsgEnum.PipedReq then reqData = curParams.data - Logger.logHighlight("[NetManager]===onSend===name:%s params:%s", ProtoMsgDispatch:getReqMsgNameByMsgId(curParams.msg_id), json.encode(reqData)) + Logger.logHighlight("[NetManager]===onSend===name:%s params:%s", + ProtoMsgDispatch:getReqMsgNameByMsgId(curParams.msg_id), json.encode(reqData)) else reqData = curParams Logger.logHighlight("[NetManager]===onSend===name:%s params:%s", subName, json.encode(reqData)) end end - local msgFullName = ProtoMsgDispatch:getMsgFullNameByMsgName(curMsgName) + local msgFullName = ProtoMsgDispatch:getMsgFullNameByMsgName(curMsgName) if curMsgName == ProtoMsgType.FromMsgEnum.PipedReq then local msgName = ProtoMsgDispatch:getReqMsgNameByMsgId(curParams.msg_id) local fullMsgName = ProtoMsgDispatch:getMsgFullNameByMsgName(msgName) @@ -520,34 +592,34 @@ function NetManager:trySend() end end - local bytes = pb.encode(msgFullName, curParams) - if bytes then - if curLockGame then - UIManager:showWaitNet() - end - local msgId = ProtoMsgDispatch:getMsgIdByMsgName(curMsgName) + local bytes = pb.encode(msgFullName, curParams) + if bytes then + if curLockGame then + UIManager:showWaitNet() + end + local msgId = ProtoMsgDispatch:getMsgIdByMsgName(curMsgName) - self:_sendBytes(curSocketName, bytes, msgId, 0) + self:_sendBytes(curSocketName, bytes, msgId, 0, noRsp) - if noRsp then - return - end - local msg = ProtoMsgDispatch:getRspMsgByMsgName(originMsgName) - if not self.receiveCallbacks[msg] then - self.receiveCallbacks[msg] = {} - end - local receiveCallback = self:getReceiveCallback() + if noRsp then + return + end + local msg = ProtoMsgDispatch:getRspMsgByMsgName(originMsgName) + if not self.receiveCallbacks[msg] then + self.receiveCallbacks[msg] = {} + end + local receiveCallback = self:getReceiveCallback() receiveCallback.binder = binder - receiveCallback.lockGame = curLockGame + receiveCallback.lockGame = curLockGame receiveCallback.callback = curCallback - receiveCallback.responseData = responseData receiveCallback.getType = getType receiveCallback.beforeOver = beforeOver - table.insert(self.receiveCallbacks[msg], receiveCallback) - else - Logger.logError("[NetManager]send data error %s", curMsgName) - end - end + receiveCallback.socketName = curSocketName + table.insert(self.receiveCallbacks[msg], receiveCallback) + else + Logger.logError("[NetManager]send data error %s", curMsgName) + end + end end -- 静默重连 @@ -559,7 +631,7 @@ end -- 主动重连 function NetManager:reconnectMain() - UIManager:showWaitNet(true) -- 强制重新计时 + UIManager:showWaitNet(true) -- 强制重新计时 if self.activeReconnectMainFlag then -- 说明之前已经在主动重连中,为了保证引用计数正确,这里减一 UIManager:hideWaitNet() else @@ -580,6 +652,7 @@ end function NetManager:recycleReceiveCallback(receiveCallback) receiveCallback.callback = nil receiveCallback.lockGame = true + receiveCallback.reqData = nil table.insert(self.receiveCallbackPool, receiveCallback) end @@ -591,30 +664,6 @@ function NetManager:disconnectAll() end end -function NetManager:disconnectAndReconnect() - if self.alreadyConnected[NetManager.MAIN_SOCKET_NAME] then - if not DataManager:getLoginSuccess() then -- 没登陆成功的,直接重新走auth->login - ModuleManager.LoginManager:reloginOnReconnectRefuse() - return - end - - 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() - end, self.mainReconnectWaitTime) - self.mainReconnectWaitTime = self.mainReconnectWaitTime + 1 - else - self:closeAll() - end -end - function NetManager:showReconnectMain() if self.reconnectMainId then SchedulerManager:unscheduleGlobal(self.reconnectMainId) @@ -624,9 +673,9 @@ function NetManager:showReconnectMain() return end local params = { - content = I18N:getGlobalText(I18N.GlobalConst.RECONNECT), + content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_DESC_2), okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), - cancelText = I18N:getGlobalText(I18N.GlobalConst.RELOGIN), + cancelText = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_DESC_3), noShowClose = true, okFunc = function() self:reconnectMain() @@ -645,7 +694,7 @@ function NetManager:disconnect(socketName) if self.isClosedMap[socketName] then return end - if socketName == NetManager.CHAT_SOCKET_NAME then --暂时没有维护 + if socketName == NetManager.CHAT_SOCKET_NAME then self.isClosedMap[socketName] = true CS.BF.BFMain.Instance.NetMgr:Close(socketName) @@ -657,19 +706,19 @@ function NetManager:disconnect(socketName) DataManager.ChatData:onDisconnect() end - self.reconnectChatId = self:performWithDelayGlobal(function () + self.reconnectChatId = self:performWithDelayGlobal(function() self.reconnectChatId = nil if not self:isConnected(NetManager.CHAT_SOCKET_NAME) then - ModuleManager.LoginManager:connectByChannel(nil, NetManager.CHAT_SOCKET_NAME) + ModuleManager.LoginManager:connectChat() end end, self.chatReconnectWaitTime) - self.chatReconnectWaitTime = self.chatReconnectWaitTime*2 + self.chatReconnectWaitTime = self.chatReconnectWaitTime * 2 if self.chatReconnectWaitTime > MAX_CHAT_WAIT_TIME then self.chatReconnectWaitTime = MAX_CHAT_WAIT_TIME end else - if self.alreadyConnected[socketName] then -- 如果是成功连接过 + if self.alreadyConnected[socketName] then -- 如果是成功连接过 if not DataManager:getLoginSuccess() then -- 没登陆成功的,直接重新走auth->login ModuleManager.LoginManager:reloginOnReconnectRefuse() return @@ -681,16 +730,17 @@ function NetManager:disconnect(socketName) end else -- 否则就悄咪咪的重连 if self.mainReconnectWaitTime > MAX_MAIN_WAIT_TIME then - self.mainReconnectWaitTime = MAX_MAIN_WAIT_TIME + 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 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() @@ -703,13 +753,13 @@ function NetManager:onDisconnect(socketName) end function NetManager:performWithDelayGlobal(func, delay) - local sid = SchedulerManager:performWithDelayGlobal(func, delay) - return sid + local sid = SchedulerManager:performWithDelayGlobal(func, delay) + return sid end function NetManager:scheduleGlobal(func, delay) - local sid = SchedulerManager:scheduleGlobal(func, delay) - return sid + local sid = SchedulerManager:scheduleGlobal(func, delay) + return sid end function NetManager:closeAll(errorType) @@ -720,21 +770,20 @@ function NetManager:closeAll(errorType) UIManager:showDisconnect(errorType) end -function NetManager:onReceive(msgId, data) - self.isSending = false +function NetManager:onReceive(msgId, data, clientName) --Logger.logHighlight("MSGID:"..msgId) local msgName = ProtoMsgDispatch:getReqMsgNameByMsgId(msgId) if msgName == nil then + self.isSending = false return end -- 这里保证即使协议有问题解不出来也不要卡住 - local ok, pbData = pcall(function() local fullMsgName = ProtoMsgDispatch:getMsgFullNameByMsgName(msgName) return pb.decode(fullMsgName, data) end) - local msg = ProtoMsgDispatch:getRspMsgByMsgName(msgName) + local msg = ProtoMsgDispatch:getRspMsgByMsgName(msgName) if ok and pbData then if not pbData.err_code then pbData.status = 0 @@ -742,19 +791,19 @@ function NetManager:onReceive(msgId, data) pbData.status = ProtoMsgDispatch:getErrCodeEnum(pbData.err_code) end if EDITOR_MODE then - -- Logger.logHighlight("[NetManager]===onReceive===name:%s, msgId:%s, data:%s", msgName, msgId, json.encode(pbData)) self:printReceive(msgName, msgId, pbData) end self:dispatch(msgName, pbData) else if EDITOR_MODE then - Logger.logHighlight("[NetManager]===onReceive failed===name:%s, msgId:%s", msgName, msgId) + Logger.logHighlight("[NetManager]===onReceive failed===name:%s, msgId:%s, err:%s", msgName, msgId, + tostring(pbData)) end end local sendInfo local sendMsgName - if self.sendQueue[1]then + if clientName ~= NetManager.CHAT_SOCKET_NAME and self.sendQueue[1] then sendMsgName = self.sendQueue[1].msgName if sendMsgName == ProtoMsgType.FromMsgEnum.PipedReq then sendMsgName = ProtoMsgDispatch:getReqMsgNameByMsgId(self.sendQueue[1].params.msg_id) @@ -763,7 +812,7 @@ function NetManager:onReceive(msgId, data) sendInfo = table.remove(self.sendQueue, 1) self:saveSendQueue() end - end + end if not ok or not pbData then local reqDataStr = GConst.EMPTY_STRING @@ -775,7 +824,7 @@ function NetManager:onReceive(msgId, data) end end BIReport:postPbDecodefailed(sendMsgName, reqDataStr) - -- elseif pbData.err_code ~= GConst.ERROR_STR.SUCCESS then + -- elseif pbData.err_code ~= GConst.ERROR_STR.SUCCESS then elseif pbData.status ~= 0 then -- 有一些协议没有err_code所以改为判定自定义的status local reqDataStr = GConst.EMPTY_STRING if sendInfo then @@ -785,48 +834,51 @@ function NetManager:onReceive(msgId, data) reqDataStr = json.encode(sendInfo.params) end end - BIReport:postNetError(sendMsgName, pbData.err_code, reqDataStr, pbData) + BIReport:postNetError(sendMsgName, pbData.status, reqDataStr, pbData) end - local callbacks = self.receiveCallbacks[msg] - if callbacks and #callbacks > 0 then - local receiveCallback = table.remove(callbacks, 1) - local lockGame = true - local receiveFunc = nil - local responseData = nil - if receiveCallback then - lockGame = receiveCallback.lockGame - receiveFunc = receiveCallback.callback - responseData = receiveCallback.responseData - if pbData.err_code == GConst.ERROR_STR.SUCCESS and pbData.rewards then + local callbacks = self.receiveCallbacks[msg] + if callbacks and #callbacks > 0 then + if clientName ~= NetManager.CHAT_SOCKET_NAME then -- 忽略推送和聊天 + self.isSending = false + end + local receiveCallback = table.remove(callbacks, 1) + local lockGame = true + local receiveFunc = nil + if receiveCallback then + lockGame = receiveCallback.lockGame + receiveFunc = receiveCallback.callback + if pbData.err_code == GConst.ERROR_STR.SUCCESS and pbData.rewards and not self:getNotAddRewardsRsp(sendMsgName) then local getType = receiveCallback.getType - if sendMsgName == "ActPayReq" then - getType = PayManager:getItemGetType(pbData.act_type, pbData.id) - elseif sendMsgName == "ActPaidResultReq" then -- 支付上报统一处理 + if sendMsgName == "GiftPayReq" then + getType = PayManager:getItemGetType(pbData.gift_type, pbData.id) + elseif sendMsgName == "GiftPaidResultReq" then -- 支付上报统一处理 if pbData.gift then for _, gift in ipairs(pbData.gift) do - getType = PayManager:getItemGetType(gift.act_type, gift.id) + getType = PayManager:getItemGetType(gift.gift_type, gift.id) break end end elseif sendMsgName == "AppStorePaidReq" then -- ios支付上报统一处理 if pbData.gift then for _, gift in ipairs(pbData.gift) do - getType = PayManager:getItemGetType(gift.act_type, gift.id) + getType = PayManager:getItemGetType(gift.gift_type, gift.id) break end end end - if EDITOR_MODE and not getType then - Logger.logFatal("sendMessage server have rewards but not getType, check it! manager = ", receiveCallback.binder.__cname) + Logger.logFatal("sendMessage server have rewards but not getType, check it! manager = ", + receiveCallback.binder.__cname) end GFunc.addRewards(pbData.rewards, getType) end - if pbData.err_code == GConst.ERROR_STR.SUCCESS and pbData.costs and not self:getNotAddCostsRsp(msgName) then + if pbData.err_code == GConst.ERROR_STR.SUCCESS and pbData.costs and not self:getNotAddCostsRsp(sendMsgName) then local getType = receiveCallback.getType - if sendMsgName == "ActPayReq" then + if sendMsgName == "GiftPayReq" then + getType = PayManager:getItemGetType(pbData.gift_type, pbData.id) + elseif sendMsgName == "ActPayReq" then getType = PayManager:getItemGetType(pbData.mall_type, pbData.id) elseif sendMsgName == "ActPaidResultReq" then -- 支付上报统一处理 if pbData.gift then @@ -837,21 +889,11 @@ function NetManager:onReceive(msgId, data) end end if EDITOR_MODE and not getType then - Logger.logFatal("sendMessage server have costs but not getType, check it! manager = ", receiveCallback.binder.__cname) + Logger.logFatal("sendMessage server have costs but not getType, check it! manager = ", + receiveCallback.binder.__cname) end GFunc.addCosts(pbData.costs, getType) end - if EDITOR_MODE and not self:getNotCheckResponse(ProtoMsgDispatch:getReqMsgByMsgName(msgName)) then -- 检查responseData - local fullMsgName = ProtoMsgDispatch:getMsgFullNameByMsgName(msgName) - local serverResult = pb.decode(fullMsgName, data) - self:checkCoin(responseData, serverResult) - if not GFunc.checkTableValueSame(responseData, serverResult, true) then - Logger.logWarningBox(msgName .. " : responseData not equate, please check it!") - Logger.logHighlight("------responseData not equate-------------") - Logger.printTable(responseData) - Logger.printTable(serverResult) - end - end if receiveCallback.beforeOver then UIManager:hideWaitNet() self.tillBeforeOverCount = self.tillBeforeOverCount - 1 @@ -859,7 +901,9 @@ function NetManager:onReceive(msgId, data) self.tillBeforeOverCount = 0 end end - self:recycleReceiveCallback(receiveCallback) + local chatReqData = receiveCallback.reqData + local receiveCallbackBinder = receiveCallback.binder + self:recycleReceiveCallback(receiveCallback) if lockGame then UIManager:hideWaitNet() end @@ -870,11 +914,13 @@ function NetManager:onReceive(msgId, data) else pbData.reqData = sendInfo.params end + elseif clientName == NetManager.CHAT_SOCKET_NAME then + pbData.reqData = chatReqData end - receiveFunc(receiveCallback.binder, pbData) + receiveFunc(receiveCallbackBinder, pbData) end - end - end + end + end if sendInfo then self:trySend() @@ -900,11 +946,11 @@ function NetManager:onError(socketName, errorType, errorMsg) elseif errorType == NetErrorCode.DNSParseDomainNameError then self:closeAll() else -- 未定义的error - self:disconnectAndReconnect() + self:disconnect(socketName) end if not self.disconnectTime then self.disconnectTime = Time:getServerTime() - BIReport:postNetWorkOpt(BIReport.NETWORK_OPT_TYPE.DISCONNECT, UIManager:getTopUIIndex(), errorType) + BIReport:postNetWorkOpt(BIReport.NETWORK_OPT_TYPE.DISCONNECT, UIManager:getTopUIIndex(), errorType, errorMsg) end elseif socketName == NetManager.CHAT_SOCKET_NAME then Logger.logHighlight("chat net error:errorType = %d, errorMsg = %s", errorType, errorMsg) @@ -918,11 +964,11 @@ function NetManager:setReconnectData() end function NetManager:dispatch(msgName, data) - if self.msgCallbacks[msgName] then - for module, callback in pairs(self.msgCallbacks[msgName]) do - callback(module, data) - end - end + if self.msgCallbacks[msgName] then + for module, callback in pairs(self.msgCallbacks[msgName]) do + callback(module, data) + end + end end function NetManager:getKickOutReasonEnum(enum) @@ -930,28 +976,39 @@ function NetManager:getKickOutReasonEnum(enum) end function NetManager:joinChatChannel() - -- if self.joinChatId then - -- SchedulerManager:unscheduleGlobal(self.joinChatId) - -- self.joinChatId = nil - -- end - -- if DataManager.ChatData:getIsJoinWorldRoom() then - -- return - -- end - -- local wordChannelId = DataManager.ChatData:getChatWorld():getLocalChatWorldChannleId() - -- local args = { - -- id = wordChannelId, - -- adjust = true -- 登录时第一次进入房间必须能接受调整,手动切房间的时候为false - -- } - -- self:send(ProtoMsgType.FromMsgEnum.JoinWorldRoomReq, args, function(data) - -- if data.status == 0 then - -- DataManager.ChatData:initChat(data) - -- else - -- self.joinChatId = self:performWithDelayGlobal(function () - -- self.joinChatId = nil - -- self:joinChatChannel() - -- end, JOIN_CHAT_INTERVAL) - -- end - -- end, NetManager.CHAT_SOCKET_NAME, true) + if self.joinChatId then + SchedulerManager:unscheduleGlobal(self.joinChatId) + self.joinChatId = nil + end + if DataManager.ChatData:getIsJoinWorldRoom() then + return + end + BIReport:postChatJoinChannel(BIReport.CHAT_CHANNEL.WORLD) + + local args = { + world_id = tostring(DataManager.PlayerData:getServerId()), + } + self:sendChat(self, ProtoMsgType.FromMsgEnum.JoinWorldRoomReq, args, self.onJoinChatChannelFinish) +end + +function NetManager:onJoinChatChannelFinish(result) + if result.err_code ~= GConst.ERROR_STR.SUCCESS then + self.joinChatId = self:performWithDelayGlobal(function() + self.joinChatId = nil + self:joinChatChannel() + end, JOIN_CHAT_INTERVAL) + BIReport:postChatJoinChannelFailed(BIReport.CHAT_CHANNEL.WORLD) + return + end + if DataManager.ChatData:getIsJoinWorldRoom() then + return + end + if result.world_id then + LocalData:setChatWorldChannelId(result.world_id) + end + DataManager.ChatData:initChat(result.messages, result.world_id) + BIReport:postChatJoinChannelSuccess(BIReport.CHAT_CHANNEL.WORLD) + ModuleManager.ChatManager:requestHistoryPersonalMessage() end function NetManager:registerMsgCallback(msgName, module, callback) @@ -986,6 +1043,7 @@ function NetManager:closeAndClear() if not self.initSucc then return end + self.alreadyClose = true if self.tillBeforeOverSid then SchedulerManager:unscheduleGlobal(self.tillBeforeOverSid) self.tillBeforeOverSid = nil @@ -1008,6 +1066,9 @@ function NetManager:closeAndClear() self.autoReAuthSid = nil end + --@TODO 2024-08-09 10:32:25 + -- ModuleManager.ChatManager:clear() + self.isSending = false self.sendQueue = {} self.tillBeforeOverCount = 0 @@ -1024,24 +1085,25 @@ function NetManager:closeAndClear() self.alreadyConnected[chatSocketName] = false CS.BF.BFMain.Instance.NetMgr:Close(mainSocketName) - -- CS.BF.BFMain.Instance.NetMgr:Close(chatSocketName) + CS.BF.BFMain.Instance.NetMgr:Close(chatSocketName) self:clearMsgCallbacks() UIManager:hideWaitNet(true) end function NetManager:saveSendQueue() - local list = {} - for _, info in ipairs(self.sendQueue) do - if not self:isNotSave(info.msgName) then - table.insert(list, { - msgName = info.msgName, - params = info.params, - socketName = info.socketName, - }) + if EDITOR_MODE then + local list = {} + for _, info in ipairs(self.sendQueue) do + if not self:isNotSave(info.msgName) then + table.insert(list, { + msgName = info.msgName, + params = info.params, + socketName = info.socketName, + }) + end end - end - if EDITOR_MODE and #list > 0 then + local printList = {} for k, v in ipairs(list) do local msgName = v.msgName @@ -1058,7 +1120,6 @@ function NetManager:saveSendQueue() end Logger.logHighlight("[NetManager]剩余消息队列缓存:%s", json.encode(printList)) end - LocalData:saveSendQueue(list) end function NetManager:isNotSave(msgName) @@ -1078,7 +1139,14 @@ function NetManager:getNotCheckResponse(msgName) end function NetManager:getNotAddCostsRsp(msgName) - if msgName == ProtoMsgType.FromMsgEnum.ChapterTrainRsp then + return false +end + +function NetManager:getNotAddRewardsRsp(msgName) + if msgName == ProtoMsgType.FromMsgEnum.ChapterSyncReq or + msgName == ProtoMsgType.FromMsgEnum.ChapterPassReq or + msgName == ProtoMsgType.FromMsgEnum.DevelopEquipReq or + msgName == ProtoMsgType.FromMsgEnum.SellEquipReq then return true end return false @@ -1086,27 +1154,22 @@ end function NetManager:pipedMessage(msgName, params) return msgName, params -- 屏蔽PipedReq - -- if msgName == ProtoMsgType.FromMsgEnum.LoginReq or - -- msgName == ProtoMsgType.FromMsgEnum.SyncReq or - -- msgName == ProtoMsgType.FromMsgEnum.IdleRewardReq or - -- msgName == ProtoMsgType.FromMsgEnum.IdleExtraRewardReq or - -- msgName == ProtoMsgType.FromMsgEnum.MailCycleReq or - -- msgName == ProtoMsgType.FromMsgEnum.GMReq then - -- return msgName, params - -- end - -- local msgId = ProtoMsgDispatch:getMsgIdByMsgName(msgName) - -- self.msgId = self.msgId + 1 - -- local pipedStruct = { - -- id = self.msgId, - -- ts = Time:getServerTime() * 1000, - -- msg_id = msgId, - -- data = params, - -- } - -- return ProtoMsgType.FromMsgEnum.PipedReq, pipedStruct +end + +function NetManager:getIsChatReconnectTimeReachMax() + return self.chatReconnectWaitTime == MAX_CHAT_WAIT_TIME +end + +function NetManager:resetChatReconnectWaitTime() + self.chatReconnectWaitTime = 1 +end + +function NetManager:getLastReceiveTime() + return self.lastReceiveTime end if EDITOR_MODE then - function NetManager:_checkDebugFuncMap() + function NetManager:_checkDebugFuncMap() if self._debugFuncMap == nil then self._debugFuncMap = { [BaseModule.sendMessage] = true, @@ -1116,37 +1179,19 @@ if EDITOR_MODE then end NetManager._releaseSend = NetManager.send - function NetManager:send(obj, msgName, params, responseData, callback, lockGame, noRsp, getType) + function NetManager:send(obj, msgName, params, callback, lockGame, noRsp, getType) -- 参数检查 - if (responseData.rewards or responseData.costs) and not getType and msgName ~= ProtoMsgType.FromMsgEnum.GMReq then - Logger.logFatal("sendMessage have rewards or have costs but not getType, check it! manager = ", self.__cname) - return - end if not params then Logger.logFatal("NetManager send params is nil %s", msgName) end - if not responseData then - Logger.logFatal("NetManager send responseData is nil %s", msgName) - end - local msgFullName = ProtoMsgDispatch:getMsgFullNameByMsgName(msgName) local bytes = pb.encode(msgFullName, params) if not bytes then Logger.logFatal("NetManager send params error %s", msgName) return end - - if not self:getNotCheckResponse(msgName) then - local fullMsgName = ProtoMsgDispatch:getMsgFullNameByMsgName(ProtoMsgDispatch:getRspMsgByMsgName(msgName)) - for name, number, type in pb.fields(fullMsgName) do - if name ~= "err_code" and responseData[name] == nil then - Logger.logFatal("NetManager send responseData error %s not have %s", msgName, name) - return - end - end - end -- end 参数检查 self:_checkDebugFuncMap() @@ -1154,37 +1199,36 @@ if EDITOR_MODE then if obj ~= NetManager and self._debugFuncMap[currFunc] == nil then Logger.logFatal("you can not call NetManager:send directly") end - local findCallback = false - if obj ~= NetManager and obj.__cname ~= "PayManager" then - for _, fieldValue in pairs(obj.class) do - if fieldValue == callback then - findCallback = true - end - end - else - findCallback = true - end + local findCallback = false + if obj ~= NetManager and obj.__cname ~= "PayManager" then + for _, fieldValue in pairs(obj.class) do + if fieldValue == callback then + findCallback = true + end + end + else + findCallback = true + end + if noRsp then + findCallback = true + end - if not findCallback then - Logger.logFatal("[NetManager]callback of NetManager:send is not %s function", obj.__cname) - end - self:_releaseSend(obj, msgName, params, responseData, callback, lockGame, noRsp, getType) + if not findCallback then + Logger.logFatal("[NetManager]callback of NetManager:send is not %s function", obj.__cname) + end + self:_releaseSend(obj, msgName, params, callback, lockGame, noRsp, getType) end NetManager._releaseSendTillBeforeOver = NetManager.sendTillBeforeOver - function NetManager:sendTillBeforeOver(obj, msgName, params, responseData, callback, ...) + function NetManager:sendTillBeforeOver(obj, msgName, params, callback, ...) self:_checkDebugFuncMap() local currFunc = debug.getinfo(2, "f").func if obj ~= NetManager and self._debugFuncMap[currFunc] == nil then Logger.logFatal("[NetManager]you can not call NetManager:send directly") end - self:_releaseSendTillBeforeOver(obj, msgName, params, responseData, callback, ...) + self:_releaseSendTillBeforeOver(obj, msgName, params, callback, ...) end end - -function NetManager:checkCoin(responseData, serverResponseData) -end - function NetManager:tagAuthFailToLogin() self.authFailToLogin = true end @@ -1193,7 +1237,6 @@ function NetManager:clearTagAuthFailToLogin() self.authFailToLogin = false end ---region 解析activities -- 解析activities中的bytes function NetManager:decodeActivityData(msgName, data) local ok, pbData = pcall(function() @@ -1221,6 +1264,5 @@ function NetManager:printReceive(msgName, msgId, pbData) end Logger.logHighlight("[NetManager]===onReceive===name:%s, msgId:%s, data:%s", msgName, msgId, json.encode(tmp)) end ---endregion -return NetManager \ No newline at end of file +return NetManager diff --git a/lua/app/ui/main_city/component/side_bar_comp.lua b/lua/app/ui/main_city/component/side_bar_comp.lua new file mode 100644 index 00000000..e5123b3a --- /dev/null +++ b/lua/app/ui/main_city/component/side_bar_comp.lua @@ -0,0 +1,363 @@ +local SideBarComp = class("SideBarComp", LuaComponent) +local UIPrefabObject = require "app/bf/unity/uiprefab_object" + +-- 侧边栏整体边距 +local SIDE_BAR_NODE_INTERVAL_X = 10 + +-- 侧边栏每项间距 +local SIDE_BAR_INTERVAL_X = 30 +local SIDE_BAR_INTERVAL_Y = 45 + +function SideBarComp:onReshow() + self:checkSideBarOpenStatus() +end + +function SideBarComp:updateTime() + self:updateSideBarStatus() +end + +function SideBarComp:init() + local uiMap = self:getUIMap() + self.leftNode = uiMap["side_bar_comp.left_node"] + self.leftSideBar = uiMap["side_bar_comp.left_node.side_bar"] + self.leftArrow = uiMap["side_bar_comp.left_node.arrow"] + self.leftArrowRp = uiMap["side_bar_comp.left_node.arrow.rp"] + self.rightNode = uiMap["side_bar_comp.right_node"] + self.rightSideBar = uiMap["side_bar_comp.right_node.side_bar"] + self.rightArrow = uiMap["side_bar_comp.right_node.arrow"] + self.rightArrowRp = uiMap["side_bar_comp.right_node.arrow.rp"] + self.sideBarCacheRoot = uiMap["side_bar_comp.cache"] + self.sideBarCellObject = uiMap["side_bar_comp.cache.side_bar_base_cell"] + + self.sideBarWidth, self.sideBarHeight = self.sideBarCellObject:fastGetSizeDelta() + self.sideBarHeight = self.sideBarHeight * 0.8 + if GConst.UI_SCREEN_HEIGHT / GConst.UI_SCREEN_WIDTH >= 2 then + self.sideBarMaxCount = 5 + else + self.sideBarMaxCount = 4 + end + + if self.showLeftSideBar == nil then + self.showLeftSideBar = true + end + if self.showRightSideBar == nil then + self.showRightSideBar = true + end + if self.leftBarList == nil then + self.leftBarList = {} + end + if self.rightBarList == nil then + self.rightBarList = {} + end + if self.sideBarCellCacheMap == nil then + self.sideBarCellCacheMap = {} + end + if self.sideBarCellAllMap == nil then + self.sideBarCellAllMap = {} + end + + self.leftArrow:addClickListener(function() + self.showLeftSideBar = not self.showLeftSideBar + self:refreshLeftSideBars() + end) + self.rightArrow:addClickListener(function() + self.showRightSideBar = not self.showRightSideBar + self:refreshRightSideBars() + end) + + -- self:bind(DataManager.PaymentData, "isDirty", function() + -- self:onReshow() + -- self:updateTime() + -- end) + -- self:bind(DataManager.SignWeekData, "isDirty", function() + -- self:updateTime() + -- end) + -- self:bind(DataManager.SignMonthData, "isDirty", function() + -- self:updateTime() + -- end) +end + +function SideBarComp:refresh() + self:refreshLeftSideBars() + self:refreshRightSideBars() + self:updateSideBarStatus() +end + +function SideBarComp:addSideBarCellComp(cellClassPath, parent) + local prefab = CS.UnityEngine.Object.Instantiate(self.sideBarCellObject:getGameObject()) + local prefabObject = UIPrefabObject:create() + prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) + prefabObject:initPrefabHelper() + prefabObject:genAllChildren() + prefabObject:setName(cellClassPath) + return prefabObject:addLuaComponent(cellClassPath) +end + +function SideBarComp:clearSideBarList(sideBarList) + local count = #sideBarList + for i = 1, count do + local cell = table.remove(sideBarList) + cell:setActive(false) + cell:setVisible(false) + self.sideBarCellCacheMap[cell:getCellPath()] = cell + end +end + +function SideBarComp:refreshLeftSideBars() + self:clearSideBarList(self.leftBarList) + self.leftArrow:setActive(false) + self.leftNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) + local list = GConst.MainCityConst.LEFT_SIDE_BARS + if #list <= 0 then + return + end + + local showCellCount = 0 + local showArrowRedPoint = false + for index, path in ipairs(list) do + local cellClass = self.sideBarCellAllMap[path] + if cellClass == nil then + cellClass = require(path) + self.sideBarCellAllMap[path] = cellClass + end + + if cellClass:checkIsOpen() then + showCellCount = showCellCount + 1 + local cell = self.sideBarCellCacheMap[path] + if cell == nil then + cell = self:addSideBarCellComp(path) + cell:getBaseObject():setParent(self.leftSideBar, false) + cell:getBaseObject():setAnchorMin(0, 1) + cell:getBaseObject():setAnchorMax(0, 1) + end + cell:initWithParentUI(self, path, true) + table.insert(self.leftBarList, cell) + + -- 侧边栏红点 + if showCellCount > GConst.MainCityConst.SIDE_BAR_MIN_COUNT and cellClass:getIsShowRedPoint() then + showArrowRedPoint = true + end + end + end + local listCount = #self.leftBarList + if listCount <= 0 then + return + end + + -- 刷新位置 + self.leftNode:setAnchoredPositionX(SIDE_BAR_NODE_INTERVAL_X) + local initX = self.sideBarWidth/2 + local addX = SIDE_BAR_INTERVAL_X + self.sideBarWidth + local initY = self.sideBarHeight/2 + local addY = SIDE_BAR_INTERVAL_Y + self.sideBarHeight + + local x = 100 + for index, cell in ipairs(self.leftBarList) do + if self.showLeftSideBar or index <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then + local addMulX = math.floor((index - 1) / self.sideBarMaxCount) + local addMulY = (index - 1) % self.sideBarMaxCount + cell:setAnchoredPositionX(initX + addMulX * addX) + cell:setAnchoredPositionY(-(initY + addMulY * addY)) + cell:refresh() + cell:setActive(true) + cell:setVisible(true) + + if addMulX >= 1 and x <= 100 then + x = (addMulX + 1) * self.sideBarWidth + SIDE_BAR_INTERVAL_X + 14 + end + else + cell:setActive(false) + cell:setVisible(false) + end + end + + local y = 110 + if listCount > GConst.MainCityConst.SIDE_BAR_MIN_COUNT then + self.leftArrow:setActive(true) + self.leftArrowRp:setVisible(false) + if self.showLeftSideBar then + local addMulY = ((listCount - 1) % self.sideBarMaxCount) + 1 + if listCount > self.sideBarMaxCount then + addMulY = self.sideBarMaxCount + end + self.leftArrow:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_GRAPHIC_FLIP).horizontal = true + self.leftArrow:setAnchoredPositionY(-(initY + addMulY * addY) - 5) + + y = initY + addMulY * addY - 10 + 27 + 14 + else + self.leftArrow:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_GRAPHIC_FLIP).horizontal = false + self.leftArrow:setAnchoredPositionY(-(initY + GConst.MainCityConst.SIDE_BAR_MIN_COUNT * addY) + 10) + self.leftArrowRp:setVisible(showArrowRedPoint) + + y = initY + GConst.MainCityConst.SIDE_BAR_MIN_COUNT * addY -10 + 27 + 14 + end + end + + self.leftNode:setSizeDelta(x, y) +end + +function SideBarComp:refreshRightSideBars() + self:clearSideBarList(self.rightBarList) + self.rightArrow:setActive(false) + self.rightNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) + local list = GConst.MainCityConst.RIGHT_SIDE_BARS + if #list <= 0 then + return + end + + local showCellCount = 0 + local showArrowRedPoint = false + for index, path in ipairs(list) do + local cellClass = self.sideBarCellAllMap[path] + if cellClass == nil then + cellClass = require(path) + self.sideBarCellAllMap[path] = cellClass + end + + if cellClass:checkIsOpen() then + showCellCount = showCellCount + 1 + local cell = self.sideBarCellCacheMap[path] + if cell == nil then + cell = self:addSideBarCellComp(path) + cell:getBaseObject():setParent(self.rightSideBar, false) + cell:getBaseObject():setAnchorMin(1, 1) + cell:getBaseObject():setAnchorMax(1, 1) + end + cell:initWithParentUI(self, path, false) + table.insert(self.rightBarList, cell) + + -- 侧边栏红点 + if showCellCount > GConst.MainCityConst.SIDE_BAR_MIN_COUNT and cellClass:getIsShowRedPoint() then + showArrowRedPoint = true + end + end + end + local listCount = #self.rightBarList + if listCount <= 0 then + return + end + + -- 刷新位置 + self.rightNode:setAnchoredPositionX(-SIDE_BAR_NODE_INTERVAL_X) + local initX = self.sideBarWidth/2 + local addX = SIDE_BAR_INTERVAL_X + self.sideBarWidth + local initY = self.sideBarHeight/2 + local addY = SIDE_BAR_INTERVAL_Y + self.sideBarHeight + local x = 100 + for index, cell in ipairs(self.rightBarList) do + if self.showRightSideBar or index <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then + local addMulX = math.floor((index - 1) / self.sideBarMaxCount) + local addMulY = (index - 1) % self.sideBarMaxCount + cell:setAnchoredPositionX(-(initX + addMulX * addX)) + cell:setAnchoredPositionY(-(initY + addMulY * addY)) + cell:refresh() + cell:setActive(true) + cell:setVisible(true) + + if addMulX >= 1 and x <= 100 then + x = (addMulX + 1) * self.sideBarWidth + SIDE_BAR_INTERVAL_X + 14 + end + else + cell:setActive(false) + cell:setVisible(false) + end + end + + local y = 110 + if listCount > GConst.MainCityConst.SIDE_BAR_MIN_COUNT then + self.rightArrow:setActive(true) + self.rightArrowRp:setVisible(false) + if self.showRightSideBar then + local addMulY = ((listCount - 1) % self.sideBarMaxCount) + 1 + if listCount > self.sideBarMaxCount then + addMulY = self.sideBarMaxCount + end + self.rightArrow:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_GRAPHIC_FLIP).horizontal = true + self.rightArrow:setAnchoredPositionY(-(initY + addMulY * addY) - 5) + + y = initY + addMulY * addY - 10 + 27 + 14 + else + self.rightArrow:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_GRAPHIC_FLIP).horizontal = false + self.rightArrow:setAnchoredPositionY(-(initY + GConst.MainCityConst.SIDE_BAR_MIN_COUNT * addY) + 10) + self.rightArrowRp:setVisible(showArrowRedPoint) + + y = initY + GConst.MainCityConst.SIDE_BAR_MIN_COUNT * addY -10 + 27 + 14 + end + end + + self.rightNode:setSizeDelta(x, y) +end + +function SideBarComp:updateSideBarStatus() + if self.leftBarList then + local refreshCount = self.showLeftSideBar and #self.leftBarList or GConst.MainCityConst.SIDE_BAR_MIN_COUNT + for i = 1, refreshCount do + local sideBarBtn = self.leftBarList[i] + if sideBarBtn then + if sideBarBtn:getIsShowRedPoint() then + sideBarBtn:showRedPoint() + else + sideBarBtn:hideRedPoint() + end + sideBarBtn:updateTime() + end + end + end + if self.rightBarList then + local refreshCount = self.showRightSideBar and #self.rightBarList or GConst.MainCityConst.SIDE_BAR_MIN_COUNT + for i = 1, refreshCount do + local sideBarBtn = self.rightBarList[i] + if sideBarBtn then + if sideBarBtn:getIsShowRedPoint() then + sideBarBtn:showRedPoint() + else + sideBarBtn:hideRedPoint() + end + sideBarBtn:updateTime() + end + end + end +end + +-- 检查侧边栏功能开启 +function SideBarComp:checkSideBarOpenStatus() + for k, CellClass in pairs(self.sideBarCellAllMap) do + local cell = self.sideBarCellCacheMap[k] + if cell and cell:getIsActive() then + if not CellClass:checkIsOpen() then + self:refreshLeftSideBars() + self:refreshRightSideBars() + end + else + if CellClass:checkIsOpen() then + self:refreshLeftSideBars() + self:refreshRightSideBars() + end + end + end +end + +-- 获取侧边栏活动入口坐标 +function SideBarComp:getSideBarActIconPos(moduleKey) + for name, cell in pairs(self.leftBarList) do + if moduleKey == cell:getModuleKey() then + return cell:getBaseObject():getPosition() + end + end + for name, cell in pairs(self.rightBarList) do + if moduleKey == cell:getModuleKey() then + return cell:getBaseObject():getPosition() + end + end + return nil +end + +function SideBarComp:closeSideBarBtn(isLeft) + if isLeft then + self:refreshLeftSideBars() + else + self:refreshRightSideBars() + end +end + +return SideBarComp \ No newline at end of file diff --git a/lua/app/ui/main_city/component/side_bar_comp.lua.meta b/lua/app/ui/main_city/component/side_bar_comp.lua.meta new file mode 100644 index 00000000..6c7e7acc --- /dev/null +++ b/lua/app/ui/main_city/component/side_bar_comp.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1507e2acdab2e42ec8474c24a7ffb49c +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 0fe052c8..464cc542 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -2,19 +2,18 @@ local UIPrefabObject = require "app/bf/unity/uiprefab_object" local MainCityUI = class("MainCityUI", BaseUI) -local SIDE_BAR_BORDER_OFFSET = 22 -local SIDE_BAR_INTERVAL = 28 -local SIDE_BAR_ARROW_INTERVAL = 20 - local BF_UI_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER local HERO_COMP = "app/ui/hero/hero_comp" local MAIN_COMP = "app/ui/main_city/component/main_comp" local SHOP_COMP = "app/ui/shop/shop_comp" local DUNGEON_COMP = "app/ui/dungeon/dungeon_comp" local COMPANY_COMP = "app/ui/company/company_comp" +local SIDE_BAR_COMP = "app/ui/main_city/component/side_bar_comp" local BOTTOM_BTN_CELL = "app/ui/main_city/cell/bottom_btn_cell" +local MAIN_COMP_INEDX = 3 + MainCityUI.CLICK_BTN_TYPE = { [1] = "HOME", [2] = "HERO", @@ -81,6 +80,7 @@ end function MainCityUI:ctor(params) self.isFirstEnter = params and params.isFirstEnter self.targetIndex = params and params.targetIndex + self.selectedIndex = params and params.targetIndex or GConst.MainCityConst.BOTTOM_PAGE.MAIN end function MainCityUI:onLoadRootComplete() @@ -96,13 +96,11 @@ function MainCityUI:onLoadRootComplete() self:updateTime() self:scheduleGlobal(function() - self:updateSideBarStatus() self:updateTime() end, 1) end function MainCityUI:onRefresh() - self:refreshAllSideBars() self:refreshSettingBtn() end @@ -111,15 +109,12 @@ function MainCityUI:onClose() self.subComps = nil end -function MainCityUI:refreshAllSideBars() - self:refreshLeftBtns() - self:refreshRightBtns() - self:updateSideBarStatus() -end - function MainCityUI:onReshow() self:checkMainPop() - self:checkSideBarOpenStatus() + -- 检查目前没开的侧边栏功能是否有可以开启的 + if self.sideBarComp then + self.sideBarComp:onReshow() + end end function MainCityUI:onSetUIOrder() @@ -195,21 +190,21 @@ function MainCityUI:_addListeners() end) self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(params) params = params or {} - local page = params.page or self.selectedInedx + local page = params.page or self.selectedIndex if page == GConst.MainCityConst.BOTTOM_PAGE.SHOP then - if self.selectedInedx == page then -- 直接跳转 + if self.selectedIndex == page then -- 直接跳转 if self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(params.storeIdx) end end -- elseif page == GConst.MainCityConst.BOTTOM_PAGE.DUNGEON then - -- if self.selectedInedx == page then -- 直接跳转 + -- if self.selectedIndex == page then -- 直接跳转 -- if self.dungeonComp then -- self.dungeonComp:refresh(params.dungeonModule) -- end -- end -- elseif page == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - -- if self.selectedInedx == page then -- 直接跳转 + -- if self.selectedIndex == page then -- 直接跳转 -- if self.mainComp then -- -- 跳转到精英 需要改变下最大关卡 -- if self.showChapterModule and self.showChapterModule == GConst.MainCityConst.MAIN_CHAPTER_MODULE.TEAM then @@ -289,6 +284,13 @@ function MainCityUI:_bind() end end end) + self:bind(DataManager.ActTimeData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + self.subComps[self.selectedIndex]:refresh() + end + self:checkMainPop() + self:refreshSideBarComp() + end) self:bind(DataManager.AIHelperData, "isDirty", function() self:refreshSettingBtn() end) @@ -398,6 +400,26 @@ function MainCityUI:refreshBottom(selectedIndex, playAnim) else self:refreshBottomCell(false) end + self:refreshSideBarComp() +end + +function MainCityUI:refreshBottomBtns() + for page, cell in pairs(self.bottomCells) do + cell:refresh(page, self.selectedIndex) + end +end + +function MainCityUI:refreshSideBarComp() + if self.sideBarComp == nil then + local uiMap = self.root:genAllChildren() + self.sideBarCompNode = uiMap["main_ui.side_bar_comp"] + self.sideBarCompNode:initPrefabHelper() + self.sideBarCompNode:genAllChildren() + self.sideBarComp = self.sideBarCompNode:addLuaComponent(SIDE_BAR_COMP) + end + + self.sideBarCompNode:setActive(self:getIsInMainPage()) + self.sideBarComp:refresh() end function MainCityUI:refreshBottomCell(showAni) @@ -406,6 +428,10 @@ function MainCityUI:refreshBottomCell(showAni) end end +function MainCityUI:getIsInMainPage() + return self.selectedIndex == MAIN_COMP_INEDX +end + function MainCityUI:initLeftRightBtns() self.leftNode = self.uiMap["main_ui.left_node"] self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"] @@ -435,300 +461,6 @@ function MainCityUI:initLeftRightBtns() self:openOrCloseRightSideBar() end) self.rightArrowImg = self.uiMap["main_ui.right_node.arrow_node.arrow"] - - self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_base_cell"] - local w, h = self.sideBarCellObject:fastGetSizeDelta() - self.sideBarHeight = h - self.sideBarMaxCount = 4 - if self.leftBarList == nil then - self.leftBarList = {} - end - if self.rightBarList == nil then - self.rightBarList = {} - end - if self.sideBarClassMap == nil then - self.sideBarClassMap = {} - end - if self.sideBarCellMap == nil then - self.sideBarCellMap = {} - end - self:recycleSideBarCells(self.leftSideBar) - self:recycleSideBarCells(self.rightSideBar) -end - -function MainCityUI:recycleSideBarCells(list) - local childList = list:getChildList() - if childList and #childList > 0 then - local count = #childList - for i = count, 1, -1 do - local child = childList[i] - local name = child:getName() - if name and name ~= "" then - child:setVisible(false) - self.sideBarCellMap[name] = child:getLuaComponent(name) - else - child:destroy() - table.remove(childList, i) - end - end - end -end - -function MainCityUI:addSideBarCellComp(cellClassPath) - local prefab = CS.UnityEngine.Object.Instantiate(self.sideBarCellObject:getGameObject()) - local prefabObject = UIPrefabObject:create() - prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) - prefabObject:initPrefabHelper() - prefabObject:genAllChildren() - prefabObject:setName(cellClassPath) - return prefabObject:addLuaComponent(cellClassPath) -end - -function MainCityUI:openOrCloseLeftSideBar() - ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose() - if self.isShowLeftSideBarArrowRedPoint ~= nil then - local isShowLeftSideBarArrowRedPoint = self.isShowLeftSideBarArrowRedPoint - self.isShowLeftSideBarArrowRedPoint = nil - self:setLeftSideBarArrowRedPoint(isShowLeftSideBarArrowRedPoint) - end -end - -function MainCityUI:refreshLeftBtns() - self:clearSideBarList(self.leftBarList) - local list = GConst.MainCityConst.LEFT_SIDE_BARS - if #list <= 0 then - return - end - local isClose = ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose() - for k, v in ipairs(list) do - local CellClass = self.sideBarClassMap[v] - if CellClass == nil then - CellClass = require(v) - self.sideBarClassMap[v] = CellClass - end - if CellClass:checkIsOpen() then - local cell = self.sideBarCellMap[v] - if cell == nil then - cell = self:addSideBarCellComp(v) - cell:getBaseObject():setParent(self.leftSideBar, false) - cell:getBaseObject():setAnchorMin(0, 1) - cell:getBaseObject():setAnchorMax(0, 1) - end - cell:initWithParentUI(self, v, true) - table.insert(self.leftBarList, cell) - end - end - local sideBarShowCount = #self.leftBarList - if sideBarShowCount <= 0 then - self.leftNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) - return - end - self.leftNode:setAnchoredPositionX(0) - local y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - local x = 60 - local maxCount = self.sideBarMaxCount - local minY = y - local bgSizeX = 112 - local otherColumn = false - if isClose then -- 只显示3个 - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.leftBarList[i] - if i <= sideBarShowCount then - sideBarBtn:setAnchoredPositionX(x) - sideBarBtn:setAnchoredPositionY(y) - sideBarBtn:refresh() - sideBarBtn:setActive(true) - sideBarBtn:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - for i = minCount + 1, sideBarShowCount do - self.leftBarList[i]:refresh() - self.leftBarList[i]:setActive(true) - self.leftBarList[i]:setVisible(false) - end - else - for k, v in ipairs(self.leftBarList) do - if maxCount == 0 then -- 换行 - y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - x = x + 110 - bgSizeX = 228 - otherColumn = true - end - - maxCount = maxCount - 1 - v:setAnchoredPositionX(x) - v:setAnchoredPositionY(y) - v:refresh() - v:setActive(true) - v:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - if sideBarShowCount <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then -- 小于3个不显示箭头 - y = y + self.sideBarHeight / 2 - if minY > y then - minY = y - end - self.leftSideBar:setSizeDeltaX(bgSizeX) - self.leftSideBar:setSizeDeltaY(-minY) - self.leftArrowBtn:stopClickAnimation() - self.leftArrowBtn:setVisible(false) - else - local arrowHeight = self.leftArrowBtn:getRectHeight() - y = y + self.sideBarHeight/2 - SIDE_BAR_ARROW_INTERVAL - arrowHeight - if minY > y then - minY = y - end - self.leftSideBar:setSizeDeltaX(bgSizeX) - self.leftSideBar:setSizeDeltaY(-minY) - self.leftArrowImg:setLocalScale(1, isClose and -1 or 1, 1) - self.leftArrowBtn:setVisible(true) - self.leftArrowBtn:setAnchoredPositionY(self.leftSideBar:fastGetAnchoredPositionY() + minY + arrowHeight/2 + SIDE_BAR_BORDER_OFFSET) - if otherColumn then - self.leftArrowBtn:setAnchoredPositionX(133) - else - self.leftArrowBtn:setAnchoredPositionX(73) - end - end -end - -function MainCityUI:openOrCloseRightSideBar() - ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose() - if self.isShowRightSideBarArrowRedPoint ~= nil then - local isShowRightSideBarArrowRedPoint = self.isShowRightSideBarArrowRedPoint - self.isShowRightSideBarArrowRedPoint = nil - self:setRightSideBarArrowRedPoint(isShowRightSideBarArrowRedPoint) - end -end - -function MainCityUI:refreshRightBtns() - self:clearSideBarList(self.rightBarList) - local list = GConst.MainCityConst.RIGHT_SIDE_BARS - if #list <= 0 then - return - end - local isClose = ModuleManager.MaincityManager:getIsMainCityRightSideBarClose() - for k, v in ipairs(list) do - local CellClass = self.sideBarClassMap[v] - if CellClass == nil then - CellClass = require(v) - self.sideBarClassMap[v] = CellClass - end - if CellClass:checkIsOpen() then - local cell = self.sideBarCellMap[v] - if cell == nil then - cell = self:addSideBarCellComp(v) - cell:getBaseObject():setParent(self.rightSideBar, false) - cell:getBaseObject():setAnchorMin(1, 1) - cell:getBaseObject():setAnchorMax(1, 1) - end - cell:initWithParentUI(self, v, false) - table.insert(self.rightBarList, cell) - end - end - local sideBarShowCount = #self.rightBarList - if #self.rightBarList <= 0 then - self.rightNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) - return - end - self.rightNode:setAnchoredPositionX(0) - local y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - local x = -60 - local maxCount = self.sideBarMaxCount - local minY = y - local bgSizeX = 112 - local otherColumn = false - if isClose then -- 只显示一个 - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.rightBarList[i] - if i <= sideBarShowCount then - sideBarBtn:setAnchoredPositionX(x) - sideBarBtn:setAnchoredPositionY(y) - sideBarBtn:refresh() - sideBarBtn:setActive(true) - sideBarBtn:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - for i = minCount + 1, sideBarShowCount do - self.rightBarList[i]:refresh() - self.rightBarList[i]:setActive(true) - self.rightBarList[i]:setVisible(false) - end - else - for k, v in ipairs(self.rightBarList) do - if maxCount == 0 then -- 换行 - y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - x = x - 110 - bgSizeX = 228 - otherColumn = true - end - maxCount = maxCount - 1 - v:setAnchoredPositionX(x) - v:setAnchoredPositionY(y) - v:refresh() - v:setActive(true) - v:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - if sideBarShowCount <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then - y = y + self.sideBarHeight / 2 - y = y + self.sideBarHeight / 2 - if minY > y then - minY = y - end - self.rightSideBar:setSizeDeltaX(bgSizeX) - self.rightSideBar:setSizeDeltaY(-minY) - self.rightArrowBtn:stopClickAnimation() - self.rightArrowBtn:setVisible(false) - else - local arrowHeight = self.rightArrowBtn:getRectHeight() - y = y + self.sideBarHeight / 2 - SIDE_BAR_ARROW_INTERVAL - arrowHeight - if minY > y then - minY = y - end - self.rightSideBar:setSizeDeltaX(bgSizeX) - self.rightSideBar:setSizeDeltaY(-minY) - self.rightArrowImg:setLocalScale(1, isClose and -1 or 1, 1) - self.rightArrowBtn:setVisible(true) - self.rightArrowBtn:setAnchoredPositionY(self.rightSideBar:fastGetAnchoredPositionY() + minY + arrowHeight/2 + SIDE_BAR_BORDER_OFFSET) - if otherColumn then - self.rightArrowBtn:setAnchoredPositionX(-133) - else - self.rightArrowBtn:setAnchoredPositionX(-73) - end - end -end - -function MainCityUI:clearSideBarList(sideBarList) - local count = #sideBarList - for i = 1, count do - local cell = table.remove(sideBarList) - cell:setActive(false) - cell:setVisible(false) - self.sideBarCellMap[cell:getCellPath()] = cell - end -end - -function MainCityUI:setSideBarVisible(visible) - self.leftNode:setVisible(visible) - self.rightNode:setVisible(visible) end function MainCityUI:refreshPlayerInfo() @@ -866,7 +598,6 @@ function MainCityUI:switchComp(index) self:switchMainCompModule() else self:setTopNodeVisible(false) - self:setSideBarVisible(false) end end @@ -878,7 +609,6 @@ function MainCityUI:switchMainCompModule(moduleKey) self.mainComp:refresh() self:checkMainPop() self:setTopNodeVisible(true) - self:setSideBarVisible(true) self:refreshBounty() self:refreshPlayerInfo() UIManager:updateBarsState(self) @@ -888,142 +618,15 @@ function MainCityUI:updateTime() if self.subComps[self.selectedIndex] and self.subComps[self.selectedIndex].refreshTime then self.subComps[self.selectedIndex]:refreshTime() end - self.inSideBarUpdate = true - if self.leftBarList then - for k, v in ipairs(self.leftBarList) do - v:updateTime() - end - end - if self.waitRefreshSideBar then - self:refreshLeftBtns() - self.waitRefreshSideBar = false - end - if self.rightBarList then - for k, v in ipairs(self.rightBarList) do - v:updateTime() - end - end - self.inSideBarUpdate = false - if self.waitRefreshSideBar then - self:refreshRightBtns() - self.waitRefreshSideBar = false - end + if self.sideBarComp then + self.sideBarComp:updateTime() + end if DataManager.AIHelperData:getNeedReqTime() then ModuleManager.GameSettingManager:reqAiHelper() end end -function MainCityUI:updateSideBarStatus() - if self.leftBarList then - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.leftBarList[i] - if sideBarBtn then - if sideBarBtn:getIsShowRedPoint() then - sideBarBtn:showRedPoint() - else - sideBarBtn:hideRedPoint() - end - end - end - local sideBarCount = #self.leftBarList - if sideBarCount > minCount then - local count = 0 - for i = minCount + 1, sideBarCount do - if self.leftBarList[i]:getIsShowRedPoint() then - self.leftBarList[i]:showRedPoint() - count = count + 1 - else - self.leftBarList[i]:hideRedPoint() - end - end - if count > 0 then - self:setLeftSideBarArrowRedPoint(true) - else - self:setLeftSideBarArrowRedPoint(false) - end - else - self:setLeftSideBarArrowRedPoint(false) - end - end - if self.rightBarList then - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.rightBarList[i] - if sideBarBtn then - if sideBarBtn:getIsShowRedPoint() then - sideBarBtn:showRedPoint() - else - sideBarBtn:hideRedPoint() - end - end - end - local sideBarCount = #self.rightBarList - if sideBarCount > minCount then - local count = 0 - for i = minCount + 1, sideBarCount do - if self.rightBarList[i]:getIsShowRedPoint() then - self.rightBarList[i]:showRedPoint() - count = count + 1 - else - self.rightBarList[i]:hideRedPoint() - end - end - if count > 0 then - self:setRightSideBarArrowRedPoint(true) - else - self:setRightSideBarArrowRedPoint(false) - end - else - self:setRightSideBarArrowRedPoint(false) - end - end -end - -function MainCityUI:setLeftSideBarArrowRedPoint(isShow) - if self.isShowLeftSideBarArrowRedPoint == isShow then - return - end - if isShow then - if ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose() then - self.leftArrowBtn:addRedPoint(19, 10, 1) - else - self.leftArrowBtn:removeRedPoint() - end - else - self.leftArrowBtn:removeRedPoint() - end -end - -function MainCityUI:setRightSideBarArrowRedPoint(isShow) - if self.isShowRightSideBarArrowRedPoint == isShow then - return - end - if isShow then - if ModuleManager.MaincityManager:getIsMainCityRightSideBarClose() then - self.rightArrowBtn:addRedPoint(19, 10, 1) - else - self.rightArrowBtn:removeRedPoint() - end - else - self.rightArrowBtn:removeRedPoint() - end -end - -function MainCityUI:closeSideBarBtn(isLeft) - if self.inSideBarUpdate then - self.waitRefreshSideBar = true - else - self.waitRefreshSideBar = false - if isLeft then - self:refreshLeftBtns() - else - self:refreshRightBtns() - end - end -end - function MainCityUI:refreshBottomRp() local uiMap = self.root:genAllChildren() local heroRpObj = uiMap["main_ui.bottom_node.icons.ui_spine_obj_2.rp_node"] @@ -1048,22 +651,6 @@ function MainCityUI:refreshSettingBtn() end end -function MainCityUI:checkSideBarOpenStatus() - -- 检查目前没开的侧边栏功能是否有可以开启的 - for k, CellClass in pairs(self.sideBarClassMap) do - local cell = self.sideBarCellMap[k] - if cell and cell:getIsActive() then - if not CellClass:checkIsOpen() then - return self:refreshAllSideBars() - end - else - if CellClass:checkIsOpen() then - return self:refreshAllSideBars() - end - end - end -end - -- 弹窗优先级: 升级>功能弹窗>英雄解锁弹窗>礼包弹窗>引导 function MainCityUI:checkMainPop() -- 续关 @@ -1345,17 +932,9 @@ function MainCityUI:getSummonIconPos() end function MainCityUI:getSideBarActIconPos(moduleKey) - for name, cell in pairs(self.leftBarList) do - if moduleKey == cell:getModuleKey() then - return cell:getBaseObject():getPosition() - end - end - for name, cell in pairs(self.rightBarList) do - if moduleKey == cell:getModuleKey() then - return cell:getBaseObject():getPosition() - end - end - return nil + if self.sideBarComp and self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + return self.sideBarComp:getSideBarActIconPos(moduleKey) + end end function MainCityUI:isInSideBarLeft(moduleKey) diff --git a/lua/app/userdata/player/player_data.lua b/lua/app/userdata/player/player_data.lua index edf776c1..24531618 100644 --- a/lua/app/userdata/player/player_data.lua +++ b/lua/app/userdata/player/player_data.lua @@ -4,7 +4,7 @@ local RECHARGE_CFG = ConfigManager:getConfig("recharge") local PlayerExpCfg = ConfigManager:getConfig("player_exp") function PlayerData:ctor() - self.data.dirty = false + self.data.isDirty = false end function PlayerData:clear() @@ -58,7 +58,7 @@ function PlayerData:init(data) self.lastLoginTime = basicInfo.lastLoginTime or Time:getBeginningOfServerToday() DataManager:registerCrossDayFunc("PlayerData", function() self:resetOnCrossDay() - self:markDirty() + self:setDirty() end) self.createTime = basicInfo.create_at or 0 -- 创角时间 @@ -98,10 +98,19 @@ function PlayerData:resetOnCrossDay() self.data.arenaTicketADCount = 0 end -function PlayerData:markDirty() +function PlayerData:setDirty() self.data.dirty = not self.data.dirty end +function PlayerData:getAuthInfo() + return self.auth +end + +function PlayerData:setAuthInfo(authInfo) + self.auth = authInfo or {} + self:setDirty() +end + function PlayerData:setVit(vit) self.vit = vit end @@ -126,7 +135,7 @@ function PlayerData:addExp(exp) if self.data.level >= self:getMaxLv() then return end - self:markDirty() + self:setDirty() end function PlayerData:setLv(level, exp) @@ -134,7 +143,7 @@ function PlayerData:setLv(level, exp) self.data.level = level self.data.exp = exp self.lvUpNeedExp = self:getNextExp(self.data.level) - self:markDirty() + self:setDirty() local data = {} data.player_level = self.data.level @@ -269,7 +278,7 @@ end function PlayerData:setNickname(name) self.data.playInfo.nickName = name self.data.playInfo.nameChanged = true - self:markDirty() + self:setDirty() end -- 是否可以免费修改昵称 @@ -292,7 +301,7 @@ end -- 设置玩家使用的头像 function PlayerData:setAvatarUsing(id) self.data.playInfo.usingAvatarId = id - self:markDirty() + self:setDirty() end -- 获取头像icon id @@ -357,7 +366,7 @@ function PlayerData:setNewAvatarStatus(id, isNew) table.removebyvalue(newIds.avatar, id, true) end LocalData:setNewAvatarAndFrame(newIds) - self:markDirty() + self:setDirty() end -- 是否显示头像(已解锁+未解锁可显示) @@ -441,7 +450,7 @@ end -- 设置玩家使用的头像框 function PlayerData:setFrameUsing(id) self.data.playInfo.usingFrameId = id - self:markDirty() + self:setDirty() end -- 获取框icon id @@ -506,7 +515,7 @@ function PlayerData:setNewFrameStatus(id, isNew) table.removebyvalue(newIds.frame, id, true) end LocalData:setNewAvatarAndFrame(newIds) - self:markDirty() + self:setDirty() end -- 是否显示头像框(已解锁+未解锁可显示)