mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 18:21:31 +00:00
Refactor EventHandlerConnector family of classes
This commit is contained in:
parent
de6afdc84a
commit
26c6c5d1e6
@ -21,6 +21,10 @@ class EventHandlerDownlinkConnector(ZMQConnectorBase):
|
|||||||
self._zmq_pull_socket.bind(address)
|
self._zmq_pull_socket.bind(address)
|
||||||
LOG.debug('Pull socket bound to %s', 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):
|
class EventHandlerUplinkConnector(ZMQConnectorBase):
|
||||||
def __init__(self, zmq_context=None):
|
def __init__(self, zmq_context=None):
|
||||||
@ -30,11 +34,9 @@ class EventHandlerUplinkConnector(ZMQConnectorBase):
|
|||||||
self._zmq_pub_socket.bind(address)
|
self._zmq_pub_socket.bind(address)
|
||||||
LOG.debug('Pub socket bound to %s', 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):
|
def send_message(self, message: dict):
|
||||||
self._zmq_pub_socket.send_multipart(serialize_tfw_msg(message))
|
self._zmq_pub_socket.send_multipart(serialize_tfw_msg(message))
|
||||||
|
|
||||||
|
|
||||||
|
class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector):
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user