summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0199.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-11-16 17:43:05 -0800
committerNathan Fritz <nathan@andyet.net>2010-11-16 17:43:05 -0800
commitb8f40eb8431dd0965d6ed3fd61956f4c91729202 (patch)
tree27aee966a5bab6ff61188445ecc8ec405acb54a4 /sleekxmpp/plugins/xep_0199.py
parentb73a8590310c61c8d56b6a6f861c8666b4e71064 (diff)
downloadslixmpp-b8f40eb8431dd0965d6ed3fd61956f4c91729202.tar.gz
slixmpp-b8f40eb8431dd0965d6ed3fd61956f4c91729202.tar.bz2
slixmpp-b8f40eb8431dd0965d6ed3fd61956f4c91729202.tar.xz
slixmpp-b8f40eb8431dd0965d6ed3fd61956f4c91729202.zip
xep_0199 ping now uses scheduler instead of dedicated threadsleek-1.0-Beta31.0-Beta3
Diffstat (limited to 'sleekxmpp/plugins/xep_0199.py')
-rw-r--r--sleekxmpp/plugins/xep_0199.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py
index 20055945..2e99ae76 100644
--- a/sleekxmpp/plugins/xep_0199.py
+++ b/sleekxmpp/plugins/xep_0199.py
@@ -21,7 +21,6 @@ class xep_0199(base.base_plugin):
self.description = "XMPP Ping"
self.xep = "0199"
self.xmpp.add_handler("<iq type='get' xmlns='%s'><ping xmlns='urn:xmpp:ping'/></iq>" % self.xmpp.default_ns, self.handler_ping, name='XMPP Ping')
- self.running = False
if self.config.get('keepalive', True):
self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True)
@@ -30,12 +29,13 @@ class xep_0199(base.base_plugin):
self.xmpp.plugin['xep_0030'].add_feature('urn:xmpp:ping')
def handler_pingserver(self, xml):
- if not self.running:
- time.sleep(self.config.get('frequency', 300))
- while self.sendPing(self.xmpp.server, self.config.get('timeout', 30)) is not False:
- time.sleep(self.config.get('frequency', 300))
+ self.xmpp.schedule("xep-0119 ping", float(self.config.get('frequency', 300)), self.scheduled_ping, repeat=True)
+
+ def scheduled_ping(self):
+ log.debug("pinging...")
+ if self.sendPing(self.xmpp.server, self.config.get('timeout', 30)) is False:
log.debug("Did not recieve ping back in time. Requesting Reconnect.")
- self.xmpp.disconnect(reconnect=True)
+ self.xmpp.reconnect()
def handler_ping(self, xml):
iq = self.xmpp.makeIqResult(xml.get('id', 'unknown'))