mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 17:51:55 +00:00
Move FSM initialization out of ZMQWebSocketHandler
This commit is contained in:
parent
8d8f55bbe6
commit
638c1b96ae
@ -23,3 +23,6 @@ class Buttons:
|
||||
def forward_message(self, event_data):
|
||||
message = event_data.kwargs.get('message')
|
||||
component_connector.send_message(message)
|
||||
|
||||
|
||||
fsm = Buttons()
|
@ -1,17 +1,15 @@
|
||||
import logging
|
||||
|
||||
from tornado.websocket import WebSocketHandler
|
||||
|
||||
from buttons import Buttons
|
||||
from util import parse_anchor_from_message
|
||||
|
||||
from buttons import fsm
|
||||
import component_connector
|
||||
|
||||
|
||||
class ZMQWebSocketHandler(WebSocketHandler):
|
||||
def __init__(self, application, request, **kwargs):
|
||||
super().__init__(application, request, **kwargs)
|
||||
self.fsm = Buttons(self)
|
||||
|
||||
def open(self, *args, **kwargs):
|
||||
def zmq_callback(msg_parts):
|
||||
@ -23,7 +21,7 @@ class ZMQWebSocketHandler(WebSocketHandler):
|
||||
|
||||
def on_message(self, message):
|
||||
logging.debug('Received on WebSocket: {}'.format(message))
|
||||
self.fsm.trigger(self._parse_anchor(message), message=message)
|
||||
fsm.trigger(parse_anchor_from_message(message), message=message)
|
||||
|
||||
def send_message(self, message: str, anchor: str = None):
|
||||
component_connector.send_message(message, anchor)
|
||||
|
Loading…
Reference in New Issue
Block a user