mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 12:31:21 +00:00
Implement message sequence numbers in ZMQWSProxy
This commit is contained in:
parent
d94bc37d48
commit
a04b078513
@ -14,6 +14,7 @@ LOG = logging.getLogger(__name__)
|
||||
class ZMQWebSocketProxy(WebSocketHandler):
|
||||
# pylint: disable=abstract-method
|
||||
instances = set()
|
||||
sequence_number = 0
|
||||
|
||||
def initialize(self, **kwargs): # pylint: disable=arguments-differ
|
||||
self._event_handler_connector = kwargs['event_handler_connector']
|
||||
@ -59,14 +60,20 @@ class ZMQWebSocketProxy(WebSocketHandler):
|
||||
"""
|
||||
Invoked on ZMQ messages from event handlers.
|
||||
"""
|
||||
self.sequence_message(message)
|
||||
LOG.debug('Received on pull socket: %s', message)
|
||||
self.proxy_eventhandler_to_websocket(message)
|
||||
|
||||
def sequence_message(self, message):
|
||||
self.sequence_number += 1
|
||||
message['seq'] = self.sequence_number
|
||||
|
||||
def on_message(self, message):
|
||||
"""
|
||||
Invoked on WS messages from frontend.
|
||||
"""
|
||||
message = json.loads(message)
|
||||
self.sequence_message(message)
|
||||
LOG.debug('Received on WebSocket: %s', message)
|
||||
self.proxy_websocket_to_eventhandler(message)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user