From 8ee658e62a1cb8694837677f6c99ff1fd0416b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 17 Jan 2018 14:58:01 +0100 Subject: [PATCH] Refactor of ZMQWebsocketHandler callback (closure -> method) --- src/app/handlers/zmq_websocket_handler.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/handlers/zmq_websocket_handler.py b/src/app/handlers/zmq_websocket_handler.py index d568388..1364409 100644 --- a/src/app/handlers/zmq_websocket_handler.py +++ b/src/app/handlers/zmq_websocket_handler.py @@ -14,13 +14,12 @@ class ZMQWebSocketHandler(WebSocketHandler): def open(self, *args, **kwargs): logging.debug('WebSocket connection initiated') + event_handler_connector.register_callback(self.zmq_callback) - def zmq_callback(msg_parts): - anchor, data = msg_parts - logging.debug('Received on pull socket: {}'.format(data.decode())) - self.write_message(data.decode()) - - event_handler_connector.register_callback(zmq_callback) + def zmq_callback(self, msg_parts): + anchor, data = msg_parts + logging.debug('Received on pull socket: {}'.format(data.decode())) + self.write_message(data.decode()) def on_message(self, message): logging.debug('Received on WebSocket: {}'.format(message))