summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-01-28 18:20:44 +0100
committermathieui <mathieui@mathieui.net>2021-01-29 15:33:44 +0100
commitfc7d7b4eb751daa030169a0b48a411e51325f01d (patch)
tree2f79dbed986785ae38ecd18d92befefc367dc4f2
parent3642e2c7f436f6c0935ebcfa3ee279d4ac22adaf (diff)
downloadslixmpp-fc7d7b4eb751daa030169a0b48a411e51325f01d.tar.gz
slixmpp-fc7d7b4eb751daa030169a0b48a411e51325f01d.tar.bz2
slixmpp-fc7d7b4eb751daa030169a0b48a411e51325f01d.tar.xz
slixmpp-fc7d7b4eb751daa030169a0b48a411e51325f01d.zip
XEP-0198: Enable SM even if we failed resuming the session
And trigger session_end only after we fail the resuming.
-rw-r--r--slixmpp/plugins/xep_0198/stream_management.py28
1 files 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):