def _recv_msg(self):
""" Route for sending message to backend. """
# Get message data
msg_data = json.loads(unquote(b64decode(req.params.data)))
# Trigger correspond event
callbacks = self._callback.get(msg_data["event"])
if callbacks:
for callback in callbacks:
callback(msg_data["data"])
# Message received
res.set_header(b"content-type", b"application/json")
return json.dumps({"status": "success"})
# Client side message subscription
# (Used to push message to client)
评论列表
文章目录