diff --git a/lib/tfw/event_handler_base.py b/lib/tfw/event_handler_base.py index aee4b93..81b1ead 100644 --- a/lib/tfw/event_handler_base.py +++ b/lib/tfw/event_handler_base.py @@ -31,10 +31,25 @@ class EventHandlerBase(ABC): a response back in case the handler returned something. This is subscribed in __init__(). """ + if not self.check_key(message): + return + response = self.dispatch_handling(message) if response: self.server_connector.send(response) + def check_key(self, message): + """ + Checks whether the message is intended for this + EventHandler. + + This is necessary because ZMQ handles PUB - SUB + connetions with pattern matching (e.g. someone + subscribed to 'fsm' will receive 'fsm_update' + messages as well. + """ + return self.key == message['key'] + def dispatch_handling(self, message): """ Used to dispatch messages to their specific handlers.