mirror of
				https://github.com/avatao-content/baseimage-tutorial-framework
				synced 2025-11-04 02:52:55 +00:00 
			
		
		
		
	Refactor EventHandlerConnector family of classes
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user