changeset 3203:fee8e33e2b3f

core (xmpp): isConnected now returns True when full connection is done: isConnected was returning True as soon as transport was connected. It is now returning True only if full connection is done (i.e. transport is connected + all plugins have been initialised).
author Goffi <goffi@goffi.org>
date Fri, 06 Mar 2020 18:19:03 +0100
parents 2e892f9f54f6
children fc2bea41e402
files sat/core/xmpp.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/core/xmpp.py	Fri Mar 06 18:19:03 2020 +0100
+++ b/sat/core/xmpp.py	Fri Mar 06 18:19:03 2020 +0100
@@ -466,11 +466,18 @@
                 yield disconnected_cb(self)
 
     def isConnected(self):
+        """Return True is client is fully connected
+
+        client is considered fully connected if transport is started and all plugins
+        are initialised
+        """
         try:
-            return bool(self.xmlstream.transport.connected)
+            transport_connected = bool(self.xmlstream.transport.connected)
         except AttributeError:
             return False
 
+        return self._connected_d is not None and transport_connected
+
     def entityDisconnect(self):
         if not self.host_app.trigger.point("disconnecting", self):
             return