mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:11:33 +00:00
Implement FSM status updates to frontend
This commit is contained in:
parent
19798f19d3
commit
35d375968b
@ -1,5 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
from tornado.websocket import WebSocketHandler
|
from tornado.websocket import WebSocketHandler
|
||||||
from util import parse_anchor_from_message
|
from util import parse_anchor_from_message
|
||||||
|
|
||||||
@ -24,6 +24,11 @@ class ZMQWebSocketHandler(WebSocketHandler):
|
|||||||
def on_message(self, message):
|
def on_message(self, message):
|
||||||
logging.debug('Received on WebSocket: {}'.format(message))
|
logging.debug('Received on WebSocket: {}'.format(message))
|
||||||
fsm.trigger(parse_anchor_from_message(message), message=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):
|
def send_message(self, message: str, anchor: str = None):
|
||||||
event_handler_connector.send_message(message, anchor)
|
event_handler_connector.send_message(message, anchor)
|
||||||
|
Loading…
Reference in New Issue
Block a user