diff --git a/lib/tfw/networking/event_handlers/server_connector.py b/lib/tfw/networking/event_handlers/server_connector.py index 678bb3b..612bb8d 100644 --- a/lib/tfw/networking/event_handlers/server_connector.py +++ b/lib/tfw/networking/event_handlers/server_connector.py @@ -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