mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 10:51:32 +00:00
Refactor ZMQWSProxy filter and callback initialization
This commit is contained in:
parent
3bc30ab503
commit
b6d72812c4
@ -32,13 +32,16 @@ class TFWServer(FSMAware):
|
||||
self.application = Application([(
|
||||
r'/ws', ZMQWebSocketProxy, {
|
||||
'event_handler_connector': self._event_handler_connector,
|
||||
'message_handlers': [
|
||||
self.handle_trigger,
|
||||
self.handle_recover,
|
||||
self.handle_fsm_update
|
||||
],
|
||||
'frontend_message_handlers': [self.save_frontend_messages]
|
||||
})])
|
||||
'proxy_filters_and_callbacks': {
|
||||
'message_handlers': [
|
||||
self.handle_trigger,
|
||||
self.handle_recover,
|
||||
self.handle_fsm_update
|
||||
],
|
||||
'frontend_message_handlers': [self.save_frontend_messages]
|
||||
}
|
||||
}
|
||||
)])
|
||||
|
||||
self._frontend_messages = FrontendMessageStorage()
|
||||
|
||||
|
@ -18,11 +18,7 @@ class ZMQWebSocketProxy(WebSocketHandler):
|
||||
|
||||
def initialize(self, **kwargs): # pylint: disable=arguments-differ
|
||||
self._event_handler_connector = kwargs['event_handler_connector']
|
||||
|
||||
self._message_handlers = kwargs.get('message_handlers', [])
|
||||
self._frontend_message_handlers = kwargs.get('frontend_message_handlers', [])
|
||||
self._eventhandler_message_handlers = kwargs.get('eventhandler_message_handlers', [])
|
||||
self._proxy_filters = kwargs.get('proxy_filters', [])
|
||||
self._proxy_filters_and_callbacks = kwargs.get('proxy_filters_and_callbacks', {})
|
||||
|
||||
self.proxy_eventhandler_to_websocket = TFWProxy(
|
||||
self.send_eventhandler_message,
|
||||
@ -36,14 +32,19 @@ class ZMQWebSocketProxy(WebSocketHandler):
|
||||
self.subscribe_proxy_callbacks()
|
||||
|
||||
def subscribe_proxy_callbacks(self):
|
||||
eventhandler_message_handlers = self._proxy_filters_and_callbacks.get('eventhandler_message_handlers', [])
|
||||
frontend_message_handlers = self._proxy_filters_and_callbacks.get('frontend_message_handlers', [])
|
||||
message_handlers = self._proxy_filters_and_callbacks.get('message_handlers', [])
|
||||
proxy_filters = self._proxy_filters_and_callbacks.get('proxy_filters', [])
|
||||
|
||||
self.proxy_websocket_to_eventhandler.subscribe_proxy_callbacks_and_filters(
|
||||
self._eventhandler_message_handlers + self._message_handlers,
|
||||
self._proxy_filters
|
||||
eventhandler_message_handlers + message_handlers,
|
||||
proxy_filters
|
||||
)
|
||||
|
||||
self.proxy_eventhandler_to_websocket.subscribe_proxy_callbacks_and_filters(
|
||||
self._frontend_message_handlers + self._message_handlers,
|
||||
self._proxy_filters
|
||||
frontend_message_handlers + message_handlers,
|
||||
proxy_filters
|
||||
)
|
||||
|
||||
def prepare(self):
|
||||
|
Loading…
Reference in New Issue
Block a user