diff --git a/lib/tfw/event_handler_base.py b/lib/tfw/event_handler_base.py index bc5d948..cca44b1 100644 --- a/lib/tfw/event_handler_base.py +++ b/lib/tfw/event_handler_base.py @@ -23,17 +23,20 @@ class EventHandlerBase(ABC): def event_handler_callback(self, msg_parts): """ Callback that is invoked when receiving a message. + Dispatches messages to handler methods and sends + a response back in case the handler returned something. This is subscribed in __init__(). """ - # TODO: fix faulty logic below message = deserialize_tfw_msg(*msg_parts) response = self.dispatch_handling(message) - response['key'] = message['key'] - if response is None: - return - self.server_connector.send(response) + if response: + response['key'] = message['key'] + self.server_connector.send(response) def dispatch_handling(self, message): + """ + Used to dispatch messages to their specific handlers. + """ if message['key'] != 'reset': return self.handle_event(message) return self.handle_reset(message) @@ -50,7 +53,7 @@ class EventHandlerBase(ABC): def handle_reset(self, message): # pylint: disable=unused-argument,no-self-use """ - 'reset' events usually receive some sort of special treatment. + Usually 'reset' events receive some sort of special treatment. :param message: the message received """