Fix EventHandlerBase.event_handler_callback broken logic

This commit is contained in:
Kristóf Tóth 2018-04-18 20:16:56 +02:00
parent 9d93d055b8
commit db1b008fc9

View File

@ -23,17 +23,20 @@ class EventHandlerBase(ABC):
def event_handler_callback(self, msg_parts): def event_handler_callback(self, msg_parts):
""" """
Callback that is invoked when receiving a message. 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__(). This is subscribed in __init__().
""" """
# TODO: fix faulty logic below
message = deserialize_tfw_msg(*msg_parts) message = deserialize_tfw_msg(*msg_parts)
response = self.dispatch_handling(message) response = self.dispatch_handling(message)
if response:
response['key'] = message['key'] response['key'] = message['key']
if response is None:
return
self.server_connector.send(response) self.server_connector.send(response)
def dispatch_handling(self, message): def dispatch_handling(self, message):
"""
Used to dispatch messages to their specific handlers.
"""
if message['key'] != 'reset': if message['key'] != 'reset':
return self.handle_event(message) return self.handle_event(message)
return self.handle_reset(message) return self.handle_reset(message)
@ -50,7 +53,7 @@ class EventHandlerBase(ABC):
def handle_reset(self, message): def handle_reset(self, message):
# pylint: disable=unused-argument,no-self-use # 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 :param message: the message received
""" """