Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-03-26 00:59:19 +0300
committerlovetox <philipp@hoerist.com>2020-03-26 00:59:35 +0300
commit452f5eabdc9d391a9cde7f19f178157e1c05751f (patch)
tree85c374247daba0baeeecb272b525879caab4785b
parent74cf3a1eceacf0935bd9a2686985127039700f62 (diff)
Client: Fix various things with pings
- Remove ping callback after disconnect - Address ping correctly to the domain instead of bare jid
-rw-r--r--nbxmpp/client.py9
-rw-r--r--nbxmpp/dispatcher.py3
2 files changed, 10 insertions, 2 deletions
diff --git a/nbxmpp/client.py b/nbxmpp/client.py
index 606ffeb..44c192c 100644
--- a/nbxmpp/client.py
+++ b/nbxmpp/client.py
@@ -103,6 +103,7 @@ class Client(Observable):
self._session_required = False
self._connect_successful = False
self._stream_close_initiated = False
+ self._ping_id = None
self._error = None, None, None
self._ignored_tls_errors = []
@@ -398,6 +399,7 @@ class Client(Observable):
def _disconnect(self, immediate=True):
self.state = StreamState.DISCONNECTING
self._remove_ping_timer()
+ self._dispatcher.remove_ping_callback(self._ping_id)
if not immediate:
self._stream_close_initiated = True
self._smacks.close_session()
@@ -772,9 +774,12 @@ class Client(Observable):
stanza.getErrorMsg())
def _ping(self):
- iq = Iq('get', to=self._jid.getBare())
+ self._ping_source_id = None
+ iq = Iq('get', to=self.domain)
iq.addChild(name='ping', namespace=NS_PING)
- self.send_stanza(iq, timeout=10, callback=self._on_pong)
+ self._ping_id = self.send_stanza(iq,
+ timeout=10,
+ callback=self._on_pong)
self._log.info('Ping')
def _on_pong(self, _client, result):
diff --git a/nbxmpp/dispatcher.py b/nbxmpp/dispatcher.py
index 8a9591e..33642e1 100644
--- a/nbxmpp/dispatcher.py
+++ b/nbxmpp/dispatcher.py
@@ -490,6 +490,9 @@ class StanzaDispatcher(Observable):
GLib.source_remove(self._timeout_id)
self._timeout_id = None
+ def remove_ping_callback(self, id_):
+ self._id_callbacks.pop(id_, None)
+
def clear_iq_callbacks(self):
self._log.info('Clear IQ callbacks')
self._id_callbacks.clear()