2018-04-03 12:49:14 +00:00
|
|
|
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
|
|
# All Rights Reserved. See LICENSE file for details.
|
|
|
|
|
2018-02-08 13:59:43 +00:00
|
|
|
import zmq
|
|
|
|
from zmq.eventloop.zmqstream import ZMQStream
|
|
|
|
|
2018-03-25 14:36:31 +00:00
|
|
|
from tfw.config import TFWENV
|
2018-04-06 13:21:45 +00:00
|
|
|
from tfw.networking 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-04-19 07:21:41 +00:00
|
|
|
self._zmq_rep_socket.connect(f'tcp://localhost:{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
|