Websocket Services¶
The WebSocketServer accepts websocket connections
from browsers and will provide different services on it.
By default, the server listens on port 8101. Deployment should be done on the same hostname as the primary UI, to ensure that authentication cookies will be sent with the websocket request.
Messages passed back and forth follow the common format:
{
"channel": "my_name",
"payload": { "data": "here" }
}
Services¶
-
class
Notifier(server=None)[source]¶ Notification broadcast server.
This service relays notifications on the
notificationschannel.Example message from the server (including channel info):
{ "channel": "notifications", "payload": { "category": "success", "last": { "category": "success", "data": {"_cls": "Notification", "_id": "585a88b208b199f61004d968", "actions": [], "category": 10, "changed_dt": "2016-12-21T14:50:42", "created_dt": "2016-12-21T14:50:42", "message": "Hello, World!"}, "id": "585a88b208b199f61004d968", "is_read": false, "label": "Hello, World!", "metainfo": {"changedDatetime": "2016-12-21T14:50:42", "changedUser": null, "createdDatetime": "2016-12-21T14:50:42", "createdUser": null} }, "unread": 3 } }
This service does not expect any messages from the client.
-
class
Clipboard(server=None)[source]¶ Clipboard server.
This service provides a synchronized clipboard for each user.
-
on_message(ws, user, message)[source]¶ Receive a clipboard command from the user.
Message should be in the format:
{ "action": "action_name", "data": "action_data" }
Where
action_nameis one of:
-
clipboard_add(user, data)[source]¶ Add a new clipboard entry with data.
Parameters: data – Raw data to be added for this entry. Returns: New clipboard with added entry.
-
clipboard_load(user, data)[source]¶ Add references to models to the clipboard.
Parameters: data (dict) – A dict with model and ids.
-
clipboard_remove(user, data)[source]¶ Remove a clipboard entry.
Parameters: data – Should be an integer ID for a clipboard entry. Returns: New clipboard with entry removed.
-