mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-26 02:31:32 +00:00
Expose TFWServer.fsm_manager as a property
This commit is contained in:
parent
770123310a
commit
f21036091c
@ -12,9 +12,9 @@ log = logging.getLogger(__name__)
|
||||
class TFWServer:
|
||||
def __init__(self, fsm_type):
|
||||
self._fsm = fsm_type()
|
||||
self.fsm_updater = FSMUpdater(self._fsm)
|
||||
self.fsm_manager = FSMManager(self._fsm)
|
||||
self._fsm.subscribe(self.fsm_updater.update)
|
||||
self._fsm_updater = FSMUpdater(self._fsm)
|
||||
self._fsm_manager = FSMManager(self._fsm)
|
||||
self._fsm.subscribe(self._fsm_updater.update)
|
||||
|
||||
self.application = Application(
|
||||
[(r'/ws', ZMQWebSocketProxy, {'make_response': self.make_response,
|
||||
@ -26,9 +26,13 @@ class TFWServer:
|
||||
def fsm(self):
|
||||
return self._fsm
|
||||
|
||||
@property
|
||||
def fsm_manager(self):
|
||||
return self._fsm_manager
|
||||
|
||||
def make_response(self, message):
|
||||
trigger = message.get('trigger', '')
|
||||
try: self.fsm_manager.trigger(trigger, message)
|
||||
try: self._fsm_manager.trigger(trigger, message)
|
||||
except AttributeError: log.debug('FSM failed to execute nonexistent trigger: "{}"'.format(trigger))
|
||||
return message
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user