Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Send periodic jabber keepalives

  • Loading branch information...
commit ea8bfc567310fba294a34acb8b0704ab506ad8f5 1 parent d82e2a4
@nelhage authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 party-zephyr.py
View
7 party-zephyr.py
@@ -10,6 +10,7 @@
import yaml
import os.path
import time
+import xmpp
SHUTDOWN = False
@@ -29,9 +30,11 @@
from_jabber_q = Queue.Queue()
PARTYCHAT_HOST = 'im.partych.at'
+KEEPALIVE_INTERVAL = 60
class BridgeBot(jabberbot.JabberBot):
def __init__(self, user, pw):
+ self.last_keepalive = time.time()
super(BridgeBot, self).__init__(user, pw)
# chandler = logging.StreamHandler()
@@ -84,6 +87,10 @@ def idle_proc(self):
super(BridgeBot, self).idle_proc()
if SHUTDOWN:
self.quit()
+ if time.time() - self.last_keepalive > KEEPALIVE_INTERVAL:
+ logging.debug("Sending jabber keepalive ping.")
+ self._send_status()
+ self.last_keepalive = time.time()
while True:
try:
m = from_zephyr_q.get(False)
Please sign in to comment.
Something went wrong with that request. Please try again.