plugin XEP-0198: don't use hooks on components

This commit is contained in:
Goffi 2019-02-02 01:05:25 +01:00
commit f537241232

View file

@ -202,6 +202,8 @@ class XEP_0198(object):
return True
def _disconnectedTrigger(self, client, reason):
if client.is_component:
return True
session = client._xep_0198_session
session.enabled = False
if session.resume_enabled:
@ -406,18 +408,20 @@ class XEP_0198(object):
d.addCallback(lambda __: client.presence.available())
def onReceive(self, element, client):
session = client._xep_0198_session
if session.enabled and element.name.lower() in C.STANZA_NAMES:
session.in_counter += 1 % MAX_COUNTER
if not client.is_component:
session = client._xep_0198_session
if session.enabled and element.name.lower() in C.STANZA_NAMES:
session.in_counter += 1 % MAX_COUNTER
def onSend(self, obj, client):
session = client._xep_0198_session
if (session.enabled
and domish.IElement.providedBy(obj)
and obj.name.lower() in C.STANZA_NAMES):
session.out_counter += 1 % MAX_COUNTER
session.buffer.appendleft(obj)
self.checkAcks(client)
if not client.is_component:
session = client._xep_0198_session
if (session.enabled
and domish.IElement.providedBy(obj)
and obj.name.lower() in C.STANZA_NAMES):
session.out_counter += 1 % MAX_COUNTER
session.buffer.appendleft(obj)
self.checkAcks(client)
def onAckRequest(self, r_elt, client):
self.sendAck(client)