mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 23:41:22 +00:00
Merge pull request #2 from avatao-content/fsmupdate
Implement FSM status updates to frontend
This commit is contained in:
commit
3fb29763f1
@ -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