diff --git a/src/components/component_base.py b/src/components/component_base.py index fa192c5..16626ae 100644 --- a/src/components/component_base.py +++ b/src/components/component_base.py @@ -1,3 +1,4 @@ +import json import zmq from zmq.eventloop import ioloop from zmq.eventloop.zmqstream import ZMQStream @@ -19,3 +20,12 @@ class ComponentBase: self.zmq_push_socket = self.zmq_context.socket(zmq.PUSH) self.zmq_push_socket.connect('tcp://localhost:{}'.format(RECEIVER_PORT)) + def message_other(self, anchor, data): + encoded_anchor = anchor.encode('utf-8') + message = { + 'anchor': anchor, + 'data': data + } + encoded_message = json.dumps(message).encode('utf-8') + self.zmq_push_socket.send_multipart([encoded_anchor, encoded_message]) +