mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:11:33 +00:00
Move FSM instantiation out of FSMManagingSocketHandler
This commit is contained in:
parent
849fd7b61c
commit
8b9f7e50cb
@ -41,12 +41,8 @@ class ZMQWebSocketHandler(WebSocketHandler):
|
|||||||
|
|
||||||
|
|
||||||
class FSMManagingSocketHandler(ZMQWebSocketHandler):
|
class FSMManagingSocketHandler(ZMQWebSocketHandler):
|
||||||
fsm = None
|
def initialize(self, fsm):
|
||||||
|
self.fsm = fsm
|
||||||
def __init__(self, FSM, application, request, **kwargs):
|
|
||||||
super().__init__(application, request, **kwargs)
|
|
||||||
if self.fsm is None:
|
|
||||||
FSMManagingSocketHandler.fsm = FSM()
|
|
||||||
self.fsm.subscribe_message_handler(self.handle_fsm_message)
|
self.fsm.subscribe_message_handler(self.handle_fsm_message)
|
||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
|
@ -4,21 +4,17 @@ import zmq
|
|||||||
from tornado.web import Application
|
from tornado.web import Application
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
|
from sql_injection_fsm import SQLInjectionFSM
|
||||||
from tfw.config import WEB_PORT
|
from tfw.config import WEB_PORT
|
||||||
from tfw.config.logs import logging
|
from tfw.config.logs import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
from tfw.networking.server.zmq_websocket_handler import FSMManagingSocketHandler
|
from tfw.networking.server.zmq_websocket_handler import FSMManagingSocketHandler
|
||||||
from sql_injection_fsm import SQLInjectionFSM
|
|
||||||
|
|
||||||
|
|
||||||
class SQLInjectionFSMManagingSocketHandler(FSMManagingSocketHandler):
|
|
||||||
def __init__(self, application, request, **kwargs):
|
|
||||||
super().__init__(SQLInjectionFSM, application, request, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
fsm = SQLInjectionFSM()
|
||||||
routes = [
|
routes = [
|
||||||
(r'/ws', SQLInjectionFSMManagingSocketHandler),
|
(r'/ws', FSMManagingSocketHandler, {'fsm': fsm}),
|
||||||
]
|
]
|
||||||
application = Application(
|
application = Application(
|
||||||
routes,
|
routes,
|
||||||
|
Loading…
Reference in New Issue
Block a user