mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 13:01:32 +00:00
Simplify ServerUplinkConnector mirror logic, add broadcast support
This commit is contained in:
parent
9f6ac6d27e
commit
381cd2b11e
@ -40,26 +40,40 @@ class ServerUplinkConnector(ZMQConnectorBase):
|
||||
|
||||
def send_to_eventhandler(self, message):
|
||||
"""
|
||||
Send a message to an event handler.
|
||||
Send a message to an event handler through the TFW server.
|
||||
|
||||
This envelopes the desired message in the 'data' field of the message to
|
||||
TFWServer, which will mirror it to event handlers.
|
||||
|
||||
:param message: JSON message you want to send
|
||||
:param message['key']: key of event handler you want to address
|
||||
"""
|
||||
nested_message = {'key': message['key'], 'data': message.pop('data')}
|
||||
message['key'] = 'mirror'
|
||||
message['data'] = nested_message
|
||||
self.send(message)
|
||||
self.send({
|
||||
'key': 'mirror',
|
||||
'data': message
|
||||
})
|
||||
|
||||
def send(self, message):
|
||||
"""
|
||||
Send a message to the TFW server
|
||||
Send a message to the frontend through the TFW server.
|
||||
|
||||
:param message: JSON message you want to send
|
||||
"""
|
||||
self._zmq_push_socket.send_multipart(serialize_tfw_msg(message))
|
||||
|
||||
def broadcast(self, message):
|
||||
"""
|
||||
Broadast a message through the TFW server.
|
||||
|
||||
This envelopes the desired message in the 'data' field of the message to
|
||||
TFWServer, which will broadast it.
|
||||
|
||||
:param message: JSON message you want to send
|
||||
"""
|
||||
self.send({
|
||||
'key': 'broadcast',
|
||||
'data': message
|
||||
})
|
||||
|
||||
|
||||
class ServerConnector(ServerUplinkConnector, ServerDownlinkConnector):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user