mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 17:11:32 +00:00
Fix EventHandlerBase.event_handler_callback broken logic
This commit is contained in:
parent
9d93d055b8
commit
db1b008fc9
@ -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)
|
||||||
response['key'] = message['key']
|
if response:
|
||||||
if response is None:
|
response['key'] = message['key']
|
||||||
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
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user