From ab9040c30ecfadfcd30acf9980946aa74c097fe4 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Sat, 4 Apr 2020 13:12:59 +0200 Subject: expose is_connecting state based on connection attempt future --- slixmpp/xmlstream/xmlstream.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index cbb7950a..594acbdd 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -380,6 +380,7 @@ class XMLStream(asyncio.BaseProtocol): "ssl_object", default=self.transport.get_extra_info("socket") ) + self._current_connection_attempt = None self.init_parser() self.send_raw(self.stream_header) self.dns_answers = None @@ -438,6 +439,9 @@ class XMLStream(asyncio.BaseProtocol): self.send(error) self.disconnect() + def is_connecting(self): + return self._current_connection_attempt is not None + def is_connected(self): return self.transport is not None -- cgit v1.2.3 From 5be46a5e688bd938f4346e71a5700a090fcda309 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Sat, 4 Apr 2020 13:13:20 +0200 Subject: fire 'disconnected' callback from abort() --- slixmpp/xmlstream/xmlstream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 594acbdd..06fa058c 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -516,6 +516,7 @@ class XMLStream(asyncio.BaseProtocol): self.event("killed") self.disconnected.set_result(True) self.disconnected = asyncio.Future() + self.event("disconnected", self.disconnect_reason) def reconnect(self, wait=2.0, reason="Reconnecting"): """Calls disconnect(), and once we are disconnected (after the timeout, or -- cgit v1.2.3