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)