local ServerPushManager = {}

---- 注册推送监听
function ServerPushManager:addServerPushListener(msgName, module, callback)
    NetManager:registerMsgCallback(msgName, module, callback)
end

---- 移除推送监听
function ServerPushManager:removeServerPushListener(msgName, module)
    NetManager:unRegisterMsgCallback(msgName, module)
end

---- 初始化全局推送监听
function ServerPushManager:initWhenLogin()
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.KickOutNtf, UIManager, UIManager.showKickOut)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.BountyBoughtNtf, ModuleManager.BountyManager, ModuleManager.BountyManager.onBoughtBountyFinish)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.ArenaBountyBoughtNtf, ModuleManager.ArenaBountyManager, ModuleManager.ArenaBountyManager.onBoughtBountyFinish)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.NewMailNtf, ModuleManager.MailManager, ModuleManager.MailManager.needUpdateMail)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.PigLevelUpNtf, ModuleManager.ActivityManager, ModuleManager.ActivityManager.onBoughtGoldPigFinish)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.TriggerLevelUpGiftNtf, ModuleManager.ShopManager, ModuleManager.ShopManager.onTriggerLevelUpGift)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.TriggerGrowUpGift2Ntf, ModuleManager.ShopManager, ModuleManager.ShopManager.onTriggerGrowUpGift)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.MallDailyResetNtf, ModuleManager.ShopManager, ModuleManager.ShopManager.onMallDailyReset)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.AIHelpUnreadNtf, ModuleManager.GameSettingManager, ModuleManager.GameSettingManager.rspAiHelperNtf)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.RecoveryNtf, ModuleManager.ItemManager, ModuleManager.ItemManager.rspRecoveryNtf)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.BossRushBoughtNtf, ModuleManager.ActBossRushManager, ModuleManager.ActBossRushManager.rspBossRushBoughtNtf)
    self:addServerPushListener(ProtoMsgType.FromMsgEnum.RuneUpdateNtf, ModuleManager.RunesManager, ModuleManager.RunesManager.rspUpdate)
end

---- 移除全局推送监听
function ServerPushManager:removeWhenLoginOut()
    self:removeServerPushListener(ProtoMsgType.FromMsgEnum.KickOutNtf, UIManager)
end

return ServerPushManager