diff --git a/src/app/buttons.py b/src/app/buttons.py index f298531..0140ede 100644 --- a/src/app/buttons.py +++ b/src/app/buttons.py @@ -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() \ No newline at end of file diff --git a/src/app/handlers/zmq_websocket_handler.py b/src/app/handlers/zmq_websocket_handler.py index 18fc09d..eecbc01 100644 --- a/src/app/handlers/zmq_websocket_handler.py +++ b/src/app/handlers/zmq_websocket_handler.py @@ -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)