baseimage-tutorial-framework/lib/tfw/networking/server/tfw_server.py

21 lines
587 B
Python
Raw Normal View History

from tornado.web import Application
from tfw.networking.server.controller_responder import ControllerResponder
from tfw.networking.server.zmq_websocket_handler import FSMManagingSocketHandler
class TFWServer:
def __init__(self, fsm_type):
self._fsm = fsm_type()
self.application = Application(
[(r'/ws', FSMManagingSocketHandler, {'fsm': self.fsm})]
)
self.controller_responder = ControllerResponder(self.fsm)
@property
def fsm(self):
return self._fsm
def listen(self, port):
self.application.listen(port)