2018-02-08 13:59:43 +00:00
|
|
|
import zmq
|
|
|
|
from zmq.eventloop.zmqstream import ZMQStream
|
|
|
|
|
2018-02-09 13:21:17 +00:00
|
|
|
from tfw.config import tfwenv
|
2018-02-13 16:44:48 +00:00
|
|
|
from tfw.networking.zmq_connector_base import ZMQConnectorBase
|
2018-02-08 13:59:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ControllerConnector(ZMQConnectorBase):
|
|
|
|
def __init__(self, zmq_context=None):
|
|
|
|
super(ControllerConnector, self).__init__(zmq_context)
|
|
|
|
self._zmq_rep_socket = self._zmq_context.socket(zmq.REP)
|
2018-02-09 13:21:17 +00:00
|
|
|
self._zmq_rep_socket.connect('tcp://localhost:{}'.format(tfwenv.CONTROLLER_PORT))
|
2018-02-08 13:59:43 +00:00
|
|
|
self._zmq_rep_stream = ZMQStream(self._zmq_rep_socket)
|
|
|
|
|
2018-02-09 13:08:14 +00:00
|
|
|
self.register_callback = self._zmq_rep_stream.on_recv_stream
|