From fc7d7b4eb751daa030169a0b48a411e51325f01d Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 28 Jan 2021 18:20:44 +0100 Subject: XEP-0198: Enable SM even if we failed resuming the session And trigger session_end only after we fail the resuming. --- slixmpp/plugins/xep_0198/stream_management.py | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/slixmpp/plugins/xep_0198/stream_management.py b/slixmpp/plugins/xep_0198/stream_management.py index 0200646a..30274ecf 100644 --- a/slixmpp/plugins/xep_0198/stream_management.py +++ b/slixmpp/plugins/xep_0198/stream_management.py @@ -198,20 +198,7 @@ class XEP_0198(BasePlugin): # We've already negotiated stream management, # so no need to do it again. return False - if not self.sm_id: - if 'bind' in self.xmpp.features: - enable = stanza.Enable(self.xmpp) - enable['resume'] = self.allow_resume - enable.send() - log.debug("enabling SM") - - waiter = Waiter('enabled_or_failed', - MatchMany([ - MatchXPath(stanza.Enabled.tag_name()), - MatchXPath(stanza.Failed.tag_name())])) - self.xmpp.register_handler(waiter) - result = await waiter.wait() - elif self.sm_id and self.allow_resume and 'bind' not in self.xmpp.features: + if self.sm_id and self.allow_resume and 'bind' not in self.xmpp.features: resume = stanza.Resume(self.xmpp) resume['h'] = self.handled resume['previd'] = self.sm_id @@ -229,6 +216,19 @@ class XEP_0198(BasePlugin): result = await waiter.wait() if result is not None and result.name == 'resumed': return True + self.xmpp.event("session_end") + if 'bind' in self.xmpp.features: + enable = stanza.Enable(self.xmpp) + enable['resume'] = self.allow_resume + enable.send() + log.debug("enabling SM") + + waiter = Waiter('enabled_or_failed', + MatchMany([ + MatchXPath(stanza.Enabled.tag_name()), + MatchXPath(stanza.Failed.tag_name())])) + self.xmpp.register_handler(waiter) + result = await waiter.wait() return False def _handle_enabled(self, stanza): -- cgit v1.2.3