From d9ba55621b5d0d22edb667d356a27ba03a901976 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 5 May 2016 18:32:04 -0700 Subject: [PATCH] Channel.add_message(server_rx=): add new arg --- src/wormhole/server/rendezvous.py | 12 ++++++------ src/wormhole/server/rendezvous_web.py | 2 +- src/wormhole/server/rendezvous_websocket.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wormhole/server/rendezvous.py b/src/wormhole/server/rendezvous.py index b4c5847..90364ed 100644 --- a/src/wormhole/server/rendezvous.py +++ b/src/wormhole/server/rendezvous.py @@ -54,25 +54,25 @@ class Channel: for ep in self._listeners: ep.send_rendezvous_event({"phase": phase, "body": body}) - def _add_message(self, side, phase, body): + def _add_message(self, side, phase, body, server_rx): db = self._db db.execute("INSERT INTO `messages`" " (`appid`, `channelid`, `side`, `phase`, `body`, `server_rx`)" " VALUES (?,?,?,?, ?,?)", (self._appid, self._channelid, side, phase, - body, time.time())) + body, server_rx)) db.commit() def allocate(self, side): - self._add_message(side, ALLOCATE, None) + self._add_message(side, ALLOCATE, None, time.time()) - def add_message(self, side, phase, body): - self._add_message(side, phase, body) + def add_message(self, side, phase, body, server_rx): + self._add_message(side, phase, body, server_rx) self.broadcast_message(phase, body) return self.get_messages() # for rendezvous_web.py POST /add def deallocate(self, side, mood): - self._add_message(side, DEALLOCATE, mood) + self._add_message(side, DEALLOCATE, mood, time.time()) db = self._db seen = set([row["side"] for row in db.execute("SELECT `side` FROM `messages`" diff --git a/src/wormhole/server/rendezvous_web.py b/src/wormhole/server/rendezvous_web.py index 9854e27..10b7b97 100644 --- a/src/wormhole/server/rendezvous_web.py +++ b/src/wormhole/server/rendezvous_web.py @@ -132,7 +132,7 @@ class Adder(RelayResource): app = self._rendezvous.get_app(appid) channel = app.get_channel(channelid) - messages = channel.add_message(side, phase, body) + messages = channel.add_message(side, phase, body, time.time()) response = {"welcome": self._welcome, "messages": messages, "sent": time.time()} return json_response(request, response) diff --git a/src/wormhole/server/rendezvous_websocket.py b/src/wormhole/server/rendezvous_websocket.py index 9667261..6c3bfd6 100644 --- a/src/wormhole/server/rendezvous_websocket.py +++ b/src/wormhole/server/rendezvous_websocket.py @@ -152,7 +152,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): raise Error("missing 'phase'") if "body" not in msg: raise Error("missing 'body'") - channel.add_message(self._side, msg["phase"], msg["body"]) + channel.add_message(self._side, msg["phase"], msg["body"], time.time()) def handle_deallocate(self, channel, msg): deleted = channel.deallocate(self._side, msg.get("mood"))