本文整理汇总了Python中messenger.proto.xmpp.XmppCooldownManager.XmppCooldownManager.getTime方法的典型用法代码示例。如果您正苦于以下问题:Python XmppCooldownManager.getTime方法的具体用法?Python XmppCooldownManager.getTime怎么用?Python XmppCooldownManager.getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messenger.proto.xmpp.XmppCooldownManager.XmppCooldownManager
的用法示例。
在下文中一共展示了XmppCooldownManager.getTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChatSessionHistoryRequester
# 需要导入模块: from messenger.proto.xmpp.XmppCooldownManager import XmppCooldownManager [as 别名]
# 或者: from messenger.proto.xmpp.XmppCooldownManager.XmppCooldownManager import getTime [as 别名]
#.........这里部分代码省略.........
def release(self):
if self.__isSuspend:
self.__isSuspend = False
self.__doNextRequest()
def suspend(self):
if not self.__isSuspend:
self.__isSuspend = True
if self.__callbackID is not None:
BigWorld.cancelCallback(self.__callbackID)
self.__callbackID = None
self.__state = _HISTORY_RQ_STATE.FREE
self.__iqID = ''
self.__history = []
return
def clear(self):
if self.__callbackID is not None:
BigWorld.cancelCallback(self.__callbackID)
self.__callbackID = None
self.__iqID = ''
self.__pool = []
self.__state = _HISTORY_RQ_STATE.FREE
return
def request(self, jid):
if self.__state == _HISTORY_RQ_STATE.UNAVAILABLE:
self.__setChannelHistory(jid)
return
if jid not in self.__pool:
self.__pool.append(jid)
if self.__isSuspend:
return
if self.__state == _HISTORY_RQ_STATE.FREE:
self.__doNextRequest()
def cancel(self, jid):
if jid in self.__pool:
if jid == self.__pool[0]:
if self.__callbackID is not None:
BigWorld.cancelCallback(self.__callbackID)
self.__callbackID = None
self.__state = _HISTORY_RQ_STATE.FREE
self.__pool.pop(0)
self.__iqID = ''
self.__history = []
self.__doNextRequest()
else:
self.__pool.remove(jid)
return
def handleIQ(self, iqID, iqType, tag):
if iqID == self.__iqID:
if iqType == IQ_TYPE.RESULT:
self.__state = _HISTORY_RQ_STATE.RESULT
elif iqType == IQ_TYPE.ERROR:
self.__state = _HISTORY_RQ_STATE.UNAVAILABLE
error = errors.createServerActionIQError(CLIENT_ACTION_ID.RQ_HISTORY, tag)
if error:
g_messengerEvents.onErrorReceived(error)
while self.__pool:
self.__setChannelHistory(self.__pool.pop(0))
result = True
else:
result = False
return result
def addHistory(self, message):
if not self.__state == _HISTORY_RQ_STATE.RESULT:
raise AssertionError
if message.body:
self.__history.append(message)
message.isFinalInHistory and self.__setChannelHistory(self.__pool.pop(0))
self.__history = []
self.__state = _HISTORY_RQ_STATE.FREE
self.__doNextRequest()
def __setChannelHistory(self, jid):
channel = self.channelsStorage.getChannel(entities.XMPPChatChannelEntity(jid))
if channel:
g_messengerEvents.channels.onHistoryReceived(sorted(self.__history, key=operator.attrgetter('sentAt')), channel)
def __doNextRequest(self):
if self.__cooldown.isInProcess(CLIENT_ACTION_ID.RQ_HISTORY):
self.__state = _HISTORY_RQ_STATE.COOLDOWN
self.__callbackID = BigWorld.callback(self.__cooldown.getTime(CLIENT_ACTION_ID.RQ_HISTORY), self.__callback)
else:
if not self.__pool:
return
self.__state = _HISTORY_RQ_STATE.WAIT
self.__iqID = self.client().sendIQ(chat_ext.GetChatHistoryQuery(self.__pool[0], self.__limit))
self.__cooldown.process(CLIENT_ACTION_ID.RQ_HISTORY, 5.0)
def __callback(self):
self.__callbackID = None
self.__state = _HISTORY_RQ_STATE.FREE
self.__doNextRequest()
return