Hotfix eventhandlers invoked several times. Waiting for server refactor.

This commit is contained in:
Kristóf Tóth 2018-02-07 10:13:06 +01:00
parent 08260f70fa
commit 849fd7b61c
2 changed files with 6 additions and 0 deletions

View File

@ -21,3 +21,6 @@ class FSMBase:
def subscribe_message_handler(self, msghandler): def subscribe_message_handler(self, msghandler):
self.message_handlers.append(msghandler) self.message_handlers.append(msghandler)
def unsubscribe_message_handler(self, msghandler):
self.message_handlers.remove(msghandler)

View File

@ -49,6 +49,9 @@ class FSMManagingSocketHandler(ZMQWebSocketHandler):
FSMManagingSocketHandler.fsm = FSM() 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):
self.fsm.unsubscribe_message_handler(self.handle_fsm_message)
def handle_fsm_message(self, message): def handle_fsm_message(self, message):
self._event_handler_connector.send_message(message) self._event_handler_connector.send_message(message)