mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 14:41:20 +00:00
Implement message broadcasting
This commit is contained in:
parent
f8233d51a9
commit
1b65bd4d3d
@ -23,7 +23,8 @@ class TFWProxy:
|
||||
self.proxy_filters.subscribe_callback(validate_message)
|
||||
|
||||
self.keyhandlers = {
|
||||
'mirror': self.mirror
|
||||
'mirror': self.mirror,
|
||||
'broadcast': self.broadcast
|
||||
}
|
||||
|
||||
def __call__(self, message):
|
||||
@ -38,16 +39,23 @@ class TFWProxy:
|
||||
if message['key'] not in self.keyhandlers:
|
||||
self.to_destination(message)
|
||||
else:
|
||||
handler = self.keyhandlers[message['key']]
|
||||
try:
|
||||
self.keyhandlers[message['key']](message)
|
||||
handler(message)
|
||||
except KeyError:
|
||||
LOG.error('Invalid mirror message format! Ignoring.')
|
||||
LOG.error('Invalid "%s" message format! Ignoring.', handler.__name__)
|
||||
|
||||
def mirror(self, message):
|
||||
message = message['data']
|
||||
LOG.debug('Mirroring message: %s', message)
|
||||
self.to_source(message)
|
||||
|
||||
def broadcast(self, message):
|
||||
message = message['data']
|
||||
LOG.debug('Broadcasting message: %s', message)
|
||||
self.to_source(message)
|
||||
self.to_destination(message)
|
||||
|
||||
|
||||
class ZMQWebSocketProxy(WebSocketHandler):
|
||||
instances = set()
|
||||
|
Loading…
Reference in New Issue
Block a user