Commit b18bd583 authored by echel0n's avatar echel0n
Browse files

Misc improvements made to websockets code

parent a1cc57dc
# Changelog
- * deb8d00 - 2018-08-24: Pre-Release v9.3.59.dev2
- * 90fdc1e - 2018-08-24: Misc improvements made to websockets code
- * a1cc57d - 2018-08-24: Pre-Release v9.3.59.dev2
- * 30e4803 - 2018-08-24: Misc improvements made to websockets code
- * 5ddb5de - 2018-08-24: Pre-Release v9.3.59.dev1
- * c0b6be8 - 2018-08-24: Added websockets support for ui messages
......
......@@ -19,7 +19,7 @@ class WebSocketUIHandler(WebSocketHandler):
clients.add(self)
for n in sickrage.app.alerts.get_notifications(self.request.remote_ip):
self.write_message(n)
self.write_message(WebSocketMessage('notification', n.data).json())
def on_message(self, message):
"""Received a message from the client."""
......@@ -58,11 +58,14 @@ class WebSocketMessage(object):
'data': self.data
}
def json(self):
"""Return the message content as a JSON-serialized string."""
return json.dumps(self.content)
def push(self):
"""Push the message to all connected WebSocket clients."""
if not clients:
return
msg = json.dumps(self.content)
for client in clients:
sickrage.app.io_loop.add_callback(client.write_message, msg)
sickrage.app.io_loop.add_callback(client.write_message, self.json())
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment