Refactor FSM triggering in TFWServer

This commit is contained in:
Kristóf Tóth 2018-04-10 13:00:56 +02:00
parent ba66188d80
commit 87fa86d314

View File

@ -38,13 +38,16 @@ class TFWServer:
return self._fsm_manager return self._fsm_manager
def make_response(self, message): def make_response(self, message):
self.trigger_fsm(message)
message['FSMUpdate'] = self._fsm_updater.get_fsm_state_and_transitions()
return message
def trigger_fsm(self, message):
trigger = message.get('trigger', '') trigger = message.get('trigger', '')
try: try:
self._fsm_manager.trigger(trigger, message) self._fsm_manager.trigger(trigger, message)
except AttributeError: except AttributeError:
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger) LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
message['FSMUpdate'] = self._fsm_updater.get_fsm_state_and_transitions()
return message
def proxy_filter(self, message): def proxy_filter(self, message):
# pylint: disable=unused-argument,no-self-use # pylint: disable=unused-argument,no-self-use