comparison sat/plugins/plugin_xep_0198.py @ 2796:fdc53c8a5439

plugin XEP-0198: don't use hooks on components
author Goffi <goffi@goffi.org>
date Sat, 02 Feb 2019 01:05:25 +0100
parents 25639611c303
children 9213c6dff48d
comparison
equal deleted inserted replaced
2795:25639611c303 2796:fdc53c8a5439
200 # to disable resuming and close normally the stream 200 # to disable resuming and close normally the stream
201 session.reset() 201 session.reset()
202 return True 202 return True
203 203
204 def _disconnectedTrigger(self, client, reason): 204 def _disconnectedTrigger(self, client, reason):
205 if client.is_component:
206 return True
205 session = client._xep_0198_session 207 session = client._xep_0198_session
206 session.enabled = False 208 session.enabled = False
207 if session.resume_enabled: 209 if session.resume_enabled:
208 session.disconnected_time = time.time() 210 session.disconnected_time = time.time()
209 session.disconnect_timer = reactor.callLater(session.session_max, 211 session.disconnect_timer = reactor.callLater(session.session_max,
404 d.addCallback(lambda __: client.roster.got_roster) 406 d.addCallback(lambda __: client.roster.got_roster)
405 # initial presence must be sent manually 407 # initial presence must be sent manually
406 d.addCallback(lambda __: client.presence.available()) 408 d.addCallback(lambda __: client.presence.available())
407 409
408 def onReceive(self, element, client): 410 def onReceive(self, element, client):
409 session = client._xep_0198_session 411 if not client.is_component:
410 if session.enabled and element.name.lower() in C.STANZA_NAMES: 412 session = client._xep_0198_session
411 session.in_counter += 1 % MAX_COUNTER 413 if session.enabled and element.name.lower() in C.STANZA_NAMES:
414 session.in_counter += 1 % MAX_COUNTER
412 415
413 def onSend(self, obj, client): 416 def onSend(self, obj, client):
414 session = client._xep_0198_session 417 if not client.is_component:
415 if (session.enabled 418 session = client._xep_0198_session
416 and domish.IElement.providedBy(obj) 419 if (session.enabled
417 and obj.name.lower() in C.STANZA_NAMES): 420 and domish.IElement.providedBy(obj)
418 session.out_counter += 1 % MAX_COUNTER 421 and obj.name.lower() in C.STANZA_NAMES):
419 session.buffer.appendleft(obj) 422 session.out_counter += 1 % MAX_COUNTER
420 self.checkAcks(client) 423 session.buffer.appendleft(obj)
424 self.checkAcks(client)
421 425
422 def onAckRequest(self, r_elt, client): 426 def onAckRequest(self, r_elt, client):
423 self.sendAck(client) 427 self.sendAck(client)
424 428
425 def onAckAnswer(self, a_elt, client): 429 def onAckAnswer(self, a_elt, client):