def _msg_polling(self):
""" Front-end message polling route. """
# Set content type
res.set_header(b"content-type", b"text/event-stream")
# Send response header
yield "retry: 2000\n\n"
# Polling loop
while True:
# Check message sending queue
while self._msg_queue:
current_msg = self._msg_queue.popleft()
yield "data: "+b64encode(quote(json.dumps(current_msg)))+"\n\n"
sleep(0)
# Server side data
评论列表
文章目录