mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-14 03:27:18 +00:00
29 lines
935 B
Python
29 lines
935 B
Python
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
# All Rights Reserved. See LICENSE file for details.
|
|
|
|
from tornado.web import Application
|
|
|
|
from tfw.networking.server.zmq_websocket_proxy import ZMQWebSocketProxy
|
|
from tfw.networking.server.event_handler_connector import EventHandlerConnector
|
|
from tfw.config.logs import logging
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class TFWServer:
|
|
"""
|
|
This class handles the proxying of messages between the frontend and event handers.
|
|
It proxies messages from the "/ws" route to all event handlers subscribed to a ZMQ
|
|
SUB socket.
|
|
"""
|
|
def __init__(self):
|
|
self._event_handler_connector = EventHandlerConnector()
|
|
self.application = Application([(
|
|
r'/ws', ZMQWebSocketProxy, {
|
|
'event_handler_connector': self._event_handler_connector,
|
|
}
|
|
)])
|
|
|
|
def listen(self, port):
|
|
self.application.listen(port)
|