def send_notification(self, name, change_type, change_info, directed_client=None):
"""Send an unsolicited notification to someone."""
# If the notification is directed, make sure it is directed at us
if directed_client is not None and self.client_id != directed_client:
return
notif_object = {'type': 'notification', 'operation': change_type, 'name': name}
if change_info is not None:
notif_object['payload'] = change_info
msg = msgpack.packb(notif_object)
try:
self.write_message(msg, binary=True)
except tornado.websocket.WebSocketClosedError:
pass
评论列表
文章目录