Advertisement
Guest User

xep_0199.patch

a guest
Nov 3rd, 2010
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. --- sleekxmpp/plugins/xep_0199.py   2010-10-27 13:58:05.567520290 +0200
  2. +++ sleekxmpp/plugins/xep_0199.py   2010-10-31 02:25:06.471567270 +0200
  3. @@ -16,19 +16,19 @@ class xep_0199(base.base_plugin):
  4.     def plugin_init(self):
  5.         self.description = "XMPP Ping"
  6.         self.xep = "0199"
  7. -       self.xmpp.add_handler("<iq type='get' xmlns='%s'><ping xmlns='http://www.xmpp.org/extensions/xep-0199.html#ns'/></iq>" % self.xmpp.default_ns, self.handler_ping, name='XMPP Ping')
  8. +       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')
  9.         self.running = False
  10. -       #if self.config.get('keepalive', True):
  11. -           #self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True)
  12. +       if self.config.get('keepalive', True):
  13. +           self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True)
  14.    
  15.     def post_init(self):
  16.         base.base_plugin.post_init(self)
  17. -       self.xmpp.plugin['xep_0030'].add_feature('http://www.xmpp.org/extensions/xep-0199.html#ns')
  18. +       self.xmpp.plugin['xep_0030'].add_feature('urn:xmpp:ping')
  19.    
  20.     def handler_pingserver(self, xml):
  21.         if not self.running:
  22.             time.sleep(self.config.get('frequency', 300))
  23. -           while self.sendPing(self.xmpp.server, self.config.get('timeout', 30)) is not False:
  24. +           while self.sendPing(self.xmpp.boundjid.host, self.config.get('timeout', 30)) is not False:
  25.                 time.sleep(self.config.get('frequency', 300))
  26.             logging.debug("Did not recieve ping back in time.  Requesting Reconnect.")
  27.             self.xmpp.disconnect(reconnect=True)
  28. @@ -47,7 +47,7 @@ class xep_0199(base.base_plugin):
  29.         iq = self.xmpp.makeIq(id)
  30.         iq.attrib['type'] = 'get'
  31.         iq.attrib['to'] = jid
  32. -       ping = ET.Element('{http://www.xmpp.org/extensions/xep-0199.html#ns}ping')
  33. +       ping = ET.Element('{urn:xmpp:ping}ping')
  34.         iq.append(ping)
  35.         startTime = time.clock()
  36.         #pingresult = self.xmpp.send(iq, self.xmpp.makeIq(id), timeout)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement