diff --git a/lib/tfw/fsm_base.py b/lib/tfw/fsm_base.py index 6557733..d6a586c 100644 --- a/lib/tfw/fsm_base.py +++ b/lib/tfw/fsm_base.py @@ -21,3 +21,6 @@ class FSMBase: def subscribe_message_handler(self, msghandler): self.message_handlers.append(msghandler) + + def unsubscribe_message_handler(self, msghandler): + self.message_handlers.remove(msghandler) diff --git a/lib/tfw/networking/server/zmq_websocket_handler.py b/lib/tfw/networking/server/zmq_websocket_handler.py index e29304d..aa55382 100644 --- a/lib/tfw/networking/server/zmq_websocket_handler.py +++ b/lib/tfw/networking/server/zmq_websocket_handler.py @@ -49,6 +49,9 @@ class FSMManagingSocketHandler(ZMQWebSocketHandler): FSMManagingSocketHandler.fsm = FSM() self.fsm.subscribe_message_handler(self.handle_fsm_message) + def on_close(self): + self.fsm.unsubscribe_message_handler(self.handle_fsm_message) + def handle_fsm_message(self, message): self._event_handler_connector.send_message(message)