mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
Don't send heartbeat events to clients that don't request them.
(imported from commit 1147814b22fb9737a807057ddbdbe0e9554086e0)
This commit is contained in:
@@ -98,13 +98,16 @@ class ClientDescriptor(object):
|
|||||||
def connect_handler(self, handler):
|
def connect_handler(self, handler):
|
||||||
self.current_handler = handler
|
self.current_handler = handler
|
||||||
self.last_connection_time = time.time()
|
self.last_connection_time = time.time()
|
||||||
|
|
||||||
|
if self.accepts_event_type('heartbeat'):
|
||||||
def timeout_callback():
|
def timeout_callback():
|
||||||
self._timeout_handle = None
|
self._timeout_handle = None
|
||||||
# All clients get heartbeat events
|
# We already checked whether the client accepts heartbeats
|
||||||
self.add_event(dict(type='heartbeat'))
|
self.add_event(dict(type='heartbeat'))
|
||||||
ioloop = tornado.ioloop.IOLoop.instance()
|
ioloop = tornado.ioloop.IOLoop.instance()
|
||||||
heartbeat_time = time.time() + HEARTBEAT_MIN_FREQ_SECS + random.randint(0, 10)
|
heartbeat_time = time.time() + HEARTBEAT_MIN_FREQ_SECS + random.randint(0, 10)
|
||||||
self._timeout_handle = ioloop.add_timeout(heartbeat_time, timeout_callback)
|
self._timeout_handle = ioloop.add_timeout(heartbeat_time, timeout_callback)
|
||||||
|
|
||||||
logging.info("DEBUG: connected handler for queue %s" % (self.event_queue.id,))
|
logging.info("DEBUG: connected handler for queue %s" % (self.event_queue.id,))
|
||||||
|
|
||||||
def disconnect_handler(self):
|
def disconnect_handler(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user