summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Lukas <georg@op-co.de>2020-03-28 20:45:39 +0100
committerGeorg Lukas <georg@op-co.de>2020-03-28 20:50:55 +0100
commitdeb6d4f1768600866390133ea083f912ae75642b (patch)
tree1020c3cbd219d620ed3390e4dc865329c9f87dfd
parent115c234527217bef1adf9e2ce611971d59905d57 (diff)
downloadslixmpp-deb6d4f1768600866390133ea083f912ae75642b.tar.gz
slixmpp-deb6d4f1768600866390133ea083f912ae75642b.tar.bz2
slixmpp-deb6d4f1768600866390133ea083f912ae75642b.tar.xz
slixmpp-deb6d4f1768600866390133ea083f912ae75642b.zip
XEP-0198: properly disable on disconnect, fix reconnect-loop
When the connection is disconnected (but the session didn't "end", because 0198 resumption is enabled), poezio will reconnect and try to send an <r/> element because the 0198 plugin doesn't realize that SM wasn't re-enabled yet.
-rw-r--r--slixmpp/plugins/xep_0198/stream_management.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0198/stream_management.py b/slixmpp/plugins/xep_0198/stream_management.py
index 759e82e1..a092736f 100644
--- a/slixmpp/plugins/xep_0198/stream_management.py
+++ b/slixmpp/plugins/xep_0198/stream_management.py
@@ -131,6 +131,7 @@ class XEP_0198(BasePlugin):
self.xmpp.add_filter('in', self._handle_incoming)
self.xmpp.add_filter('out_sync', self._handle_outgoing)
+ self.xmpp.add_event_handler('disconnected', self.disconnected)
self.xmpp.add_event_handler('session_end', self.session_end)
def plugin_end(self):
@@ -139,6 +140,7 @@ class XEP_0198(BasePlugin):
self.xmpp.unregister_feature('sm', self.order)
self.xmpp.unregister_feature('sm', self.resume_order)
+ self.xmpp.del_event_handler('disconnected', self.disconnected)
self.xmpp.del_event_handler('session_end', self.session_end)
self.xmpp.del_filter('in', self._handle_incoming)
self.xmpp.del_filter('out_sync', self._handle_outgoing)
@@ -154,6 +156,10 @@ class XEP_0198(BasePlugin):
self.xmpp.remove_stanza(stanza.Ack)
self.xmpp.remove_stanza(stanza.RequestAck)
+ def disconnected(self, event):
+ """Reset enabled state until we can resume/reenable."""
+ self.enabled = False
+
def session_end(self, event):
"""Reset stream management state."""
self.enabled = False