Refactor EventHandlerConnector family of classes

This commit is contained in:
Kristóf Tóth 2019-05-21 13:44:02 +02:00
parent de6afdc84a
commit 26c6c5d1e6

View File

@ -21,6 +21,10 @@ class EventHandlerDownlinkConnector(ZMQConnectorBase):
self._zmq_pull_socket.bind(address)
LOG.debug('Pull socket bound to %s', address)
def register_callback(self, callback):
callback = with_deserialize_tfw_msg(callback)
self._zmq_pull_stream.on_recv(callback)
class EventHandlerUplinkConnector(ZMQConnectorBase):
def __init__(self, zmq_context=None):
@ -30,11 +34,9 @@ class EventHandlerUplinkConnector(ZMQConnectorBase):
self._zmq_pub_socket.bind(address)
LOG.debug('Pub socket bound to %s', address)
class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector):
def register_callback(self, callback):
callback = with_deserialize_tfw_msg(callback)
self._zmq_pull_stream.on_recv(callback)
def send_message(self, message: dict):
self._zmq_pub_socket.send_multipart(serialize_tfw_msg(message))
class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector):
pass