From 959ab4bacab5233547960def93b32ecf9f0392aa Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 5 May 2016 18:43:43 -0700 Subject: [PATCH] rdv_ws: get server_rx at a better place --- src/wormhole/server/rendezvous_websocket.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wormhole/server/rendezvous_websocket.py b/src/wormhole/server/rendezvous_websocket.py index 6c3bfd6..1000b0d 100644 --- a/src/wormhole/server/rendezvous_websocket.py +++ b/src/wormhole/server/rendezvous_websocket.py @@ -66,6 +66,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): self.send("welcome", welcome=rv.get_welcome()) def onMessage(self, payload, isBinary): + server_rx = time.time() msg = json.loads(payload.decode("utf-8")) try: if "type" not in msg: @@ -90,7 +91,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): if mtype == "watch": return self.handle_watch(self._channel, msg) if mtype == "add": - return self.handle_add(self._channel, msg) + return self.handle_add(self._channel, msg, server_rx) if mtype == "deallocate": return self.handle_deallocate(self._channel, msg) @@ -147,12 +148,12 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): for old_message in channel.add_listener(self): self.send_rendezvous_event(old_message) - def handle_add(self, channel, msg): + def handle_add(self, channel, msg, server_rx): if "phase" not in msg: raise Error("missing 'phase'") if "body" not in msg: raise Error("missing 'body'") - channel.add_message(self._side, msg["phase"], msg["body"], time.time()) + channel.add_message(self._side, msg["phase"], msg["body"], server_rx) def handle_deallocate(self, channel, msg): deleted = channel.deallocate(self._side, msg.get("mood"))