Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0166.py @ 1617:d05f9179fe22
plugin XEP-0166: added delayedContentTerminate to terminate a content inside a handler
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 17 Nov 2015 19:41:30 +0100 |
parents | 1e05b776a55b |
children | c25f63215632 |
comparison
equal
deleted
inserted
replaced
1616:1e05b776a55b | 1617:d05f9179fe22 |
---|---|
23 from sat.tools import xml_tools | 23 from sat.tools import xml_tools |
24 log = getLogger(__name__) | 24 log = getLogger(__name__) |
25 from sat.core import exceptions | 25 from sat.core import exceptions |
26 from twisted.words.protocols.jabber import jid | 26 from twisted.words.protocols.jabber import jid |
27 from twisted.internet import defer | 27 from twisted.internet import defer |
28 from twisted.internet import reactor | |
28 from wokkel import disco, iwokkel | 29 from wokkel import disco, iwokkel |
29 from twisted.words.protocols.jabber import error | 30 from twisted.words.protocols.jabber import error |
30 from twisted.words.protocols.jabber import xmlstream | 31 from twisted.words.protocols.jabber import xmlstream |
31 from twisted.python import failure | 32 from twisted.python import failure |
32 from collections import namedtuple | 33 from collections import namedtuple |
358 | 359 |
359 d = iq_elt.send() | 360 d = iq_elt.send() |
360 d.addErrback(self._iqError, sid, client) | 361 d.addErrback(self._iqError, sid, client) |
361 yield d | 362 yield d |
362 | 363 |
364 def delayedContentTerminate(self, *args, **kwargs): | |
365 """Put contentTerminate in queue but don't execute immediately | |
366 | |
367 This is used to terminate a content inside a handler, to avoid modifying contents | |
368 """ | |
369 reactor.callLater(0, self.contentTerminate, *args, **kwargs) | |
370 | |
363 def contentTerminate(self, session, content_name, reason=REASON_SUCCESS, profile=C.PROF_KEY_NONE): | 371 def contentTerminate(self, session, content_name, reason=REASON_SUCCESS, profile=C.PROF_KEY_NONE): |
364 """Terminate and remove a content | 372 """Terminate and remove a content |
365 | 373 |
366 if there is no more content, then session is terminated | 374 if there is no more content, then session is terminated |
367 @param session(dict): jingle session | 375 @param session(dict): jingle session |