Implement FSMUpdates to EventHandlers

This commit is contained in:
Kristóf Tóth 2018-04-06 17:09:35 +02:00
parent b785b88af6
commit de8c2ae6e2

View File

@ -43,6 +43,7 @@ class TFWServer:
self._fsm_manager.trigger(trigger, message)
except AttributeError:
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):
@ -95,7 +96,10 @@ class FSMUpdater:
def generate_fsm_update(self):
key = 'FSMUpdate'
response = {'data': {'current_state': self.fsm.state,
'valid_transitions':
[{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]}}
response = {'data': self.get_fsm_state_and_transitions()}
return key, response
def get_fsm_state_and_transitions(self):
state = self.fsm.state
valid_transitions = [{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]
return {'current_state': state, 'valid_transitions': valid_transitions}