2018-02-11 11:32:30 +00:00
|
|
|
from tornado.web import Application
|
|
|
|
|
2018-02-12 12:22:55 +00:00
|
|
|
from tfw.networking.server.controller_responder import ControllerResponder
|
2018-02-11 11:32:30 +00:00
|
|
|
from tfw.networking.server.zmq_websocket_handler import FSMManagingSocketHandler
|
|
|
|
|
|
|
|
|
|
|
|
class TFWServer:
|
|
|
|
def __init__(self, fsm_type):
|
|
|
|
self._fsm = fsm_type()
|
|
|
|
self.application = Application(
|
2018-02-12 10:09:28 +00:00
|
|
|
[(r'/ws', FSMManagingSocketHandler, {'fsm': self.fsm})]
|
2018-02-11 11:32:30 +00:00
|
|
|
)
|
2018-02-12 12:22:55 +00:00
|
|
|
self.controller_responder = ControllerResponder(self.fsm)
|
2018-02-11 11:32:30 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def fsm(self):
|
|
|
|
return self._fsm
|
|
|
|
|
|
|
|
def listen(self, port):
|
|
|
|
self.application.listen(port)
|