邮件拉去增加一个随机延时
This commit is contained in:
parent
63269b6af6
commit
4ce2af94e0
@ -10,10 +10,20 @@ function MailManager:getMailList(force)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.needUpdateMailSid then
|
||||||
|
self:unscheduleGlobal(self.needUpdateMailSid)
|
||||||
|
self.needUpdateMailSid = nil
|
||||||
|
end
|
||||||
|
|
||||||
self:sendMessage(ProtoMsgType.FromMsgEnum.MailListReq, {}, {}, self.getMailListFinish)
|
self:sendMessage(ProtoMsgType.FromMsgEnum.MailListReq, {}, {}, self.getMailListFinish)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MailManager:getMailListFinish(result)
|
function MailManager:getMailListFinish(result)
|
||||||
|
if self.needUpdateMailSid then
|
||||||
|
self:unscheduleGlobal(self.needUpdateMailSid)
|
||||||
|
self.needUpdateMailSid = nil
|
||||||
|
end
|
||||||
|
|
||||||
if result.status == 0 then
|
if result.status == 0 then
|
||||||
DataManager.MailData:init(result)
|
DataManager.MailData:init(result)
|
||||||
end
|
end
|
||||||
@ -128,8 +138,18 @@ function MailManager:readMailFinish(result)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MailManager:needUpdateMail()
|
function MailManager:needUpdateMail()
|
||||||
-- 收到推送后不一定是有新邮件,要去拉一下
|
if DataManager.MailData:getNeedGetNewMail() then
|
||||||
self:getMailList(true)
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 收到推送后不一定是有新邮件,要去拉一下, 延迟是为了减轻服务器压力
|
||||||
|
if self.needUpdateMailSid then
|
||||||
|
self:unscheduleGlobal(self.needUpdateMailSid)
|
||||||
|
self.needUpdateMailSid = nil
|
||||||
|
end
|
||||||
|
self.needUpdateMailSid = self:performWithDelayGlobal(function()
|
||||||
|
self:getMailList(true)
|
||||||
|
end, math.random(1, 5))
|
||||||
end
|
end
|
||||||
|
|
||||||
return MailManager
|
return MailManager
|
||||||
Loading…
x
Reference in New Issue
Block a user