Fix ZMQWSProxy not executing filters/callbacks on nested messages

This commit is contained in:
Kristóf Tóth 2018-07-25 15:45:54 +02:00
parent 5715c57ebc
commit ca09e868f1

View File

@ -105,14 +105,9 @@ class TFWProxy:
raise ValueError('Invalid TFW message format!') raise ValueError('Invalid TFW message format!')
def __call__(self, message): def __call__(self, message):
try: if not self.filter_and_execute_callbacks(message):
self.proxy_filters._execute_callbacks(message)
except ValueError:
LOG.exception('Invalid TFW message received!')
return return
self.proxy_callbacks._execute_callbacks(message)
if message['key'] not in self.keyhandlers: if message['key'] not in self.keyhandlers:
self.to_destination(message) self.to_destination(message)
else: else:
@ -122,13 +117,26 @@ class TFWProxy:
except KeyError: except KeyError:
LOG.error('Invalid "%s" message format! Ignoring.', handler.__name__) LOG.error('Invalid "%s" message format! Ignoring.', handler.__name__)
def filter_and_execute_callbacks(self, message):
try:
self.proxy_filters._execute_callbacks(message)
self.proxy_callbacks._execute_callbacks(message)
return True
except ValueError:
LOG.exception('Invalid TFW message received!')
return False
def mirror(self, message): def mirror(self, message):
message = message['data'] message = message['data']
if not self.filter_and_execute_callbacks(message):
return
LOG.debug('Mirroring message: %s', message) LOG.debug('Mirroring message: %s', message)
self.to_source(message) self.to_source(message)
def broadcast(self, message): def broadcast(self, message):
message = message['data'] message = message['data']
if not self.filter_and_execute_callbacks(message):
return
LOG.debug('Broadcasting message: %s', message) LOG.debug('Broadcasting message: %s', message)
self.to_source(message) self.to_source(message)
self.to_destination(message) self.to_destination(message)