From 35d375968bd7e9a422ab261623bde08ded8f0afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 26 Jan 2018 15:15:05 +0100 Subject: [PATCH] Implement FSM status updates to frontend --- src/app/handlers/zmq_websocket_handler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/handlers/zmq_websocket_handler.py b/src/app/handlers/zmq_websocket_handler.py index 1364409..267434e 100644 --- a/src/app/handlers/zmq_websocket_handler.py +++ b/src/app/handlers/zmq_websocket_handler.py @@ -1,5 +1,5 @@ import logging - +import json from tornado.websocket import WebSocketHandler from util import parse_anchor_from_message @@ -24,6 +24,11 @@ class ZMQWebSocketHandler(WebSocketHandler): def on_message(self, message): logging.debug('Received on WebSocket: {}'.format(message)) fsm.trigger(parse_anchor_from_message(message), message=message) + anchor = 'FSMUpdate' + response = { 'anchor': anchor, + 'data': { 'current_state': fsm.state, + 'valid_transitions': [{'trigger': trigger} for trigger in fsm.machine.get_triggers()]}} + self.send_message(json.dumps(response), anchor) def send_message(self, message: str, anchor: str = None): event_handler_connector.send_message(message, anchor)