From 3463bf46c65f091f42643bc3f777ac05620192b6 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Thu, 10 Feb 2011 13:45:35 -0800 Subject: added option to return false on ping error, added ping example --- sleekxmpp/plugins/xep_0199.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/plugins/xep_0199.py') diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py index 16e79e26..e7ec5c46 100644 --- a/sleekxmpp/plugins/xep_0199.py +++ b/sleekxmpp/plugins/xep_0199.py @@ -42,7 +42,7 @@ class xep_0199(base.base_plugin): iq.attrib['to'] = xml.get('from', self.xmpp.boundjid.domain) self.xmpp.send(iq) - def sendPing(self, jid, timeout = 30): + def sendPing(self, jid, timeout = 30, errorfalse=False): """ sendPing(jid, timeout) Sends a ping to the specified jid, returning the time (in seconds) to receive a reply, or None if no reply is received in timeout seconds. @@ -57,7 +57,7 @@ class xep_0199(base.base_plugin): #pingresult = self.xmpp.send(iq, self.xmpp.makeIq(id), timeout) pingresult = iq.send() endTime = time.clock() - if pingresult == False: + if pingresult == False or (errorfalse and pingresult['type'] == 'error'): #self.xmpp.disconnect(reconnect=True) return False return endTime - startTime -- cgit v1.2.3