rdv_ws: deliver "server_tx", not "sent"

Update twisted/transcribe.py to accept it, update tests.
This commit is contained in:
Brian Warner 2016-05-05 18:43:49 -07:00
parent d2dfc325d8
commit 8a80242532
3 changed files with 6 additions and 6 deletions

View File

@ -161,7 +161,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
def send(self, mtype, **kwargs):
kwargs["type"] = mtype
kwargs["sent"] = time.time()
kwargs["server_tx"] = time.time()
payload = json.dumps(kwargs).encode("utf-8")
self.sendMessage(payload, False)

View File

@ -685,8 +685,8 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
self.assertEqual(msg["type"], "message")
self.assertEqual(strip_message(msg["message"]),
{"phase": "1", "body": "msg1A"})
self.assertIn("sent", msg)
self.assertIsInstance(msg["sent"], float)
self.assertIn("server_tx", msg)
self.assertIsInstance(msg["server_tx"], float)
c1.send(u"add", phase="1", body="msg1B")
c1.send(u"add", phase="2", body="msg2A")

View File

@ -140,7 +140,7 @@ class Wormhole:
return meth(msg)
def _ws_handle_welcome(self, msg):
self._timing.add("welcome").server_sent(msg["sent"])
self._timing.add("welcome").server_sent(msg["server_tx"])
welcome = msg["welcome"]
if ("motd" in welcome and
not self.motd_displayed):
@ -191,7 +191,7 @@ class Wormhole:
self._wakeup()
def _ws_handle_error(self, msg):
self._timing.add("error").server_sent(msg["sent"])
self._timing.add("error").server_sent(msg["server_tx"])
err = ServerError("%s: %s" % (msg["error"], msg["orig"]),
self._ws_url)
return self._signal_error(err)
@ -224,7 +224,7 @@ class Wormhole:
returnValue(code)
def _ws_handle_allocated(self, msg):
self._allocate_t.server_sent(msg["sent"])
self._allocate_t.server_sent(msg["server_tx"])
if self._channelid is not None:
return self._signal_error("got duplicate channelid")
self._channelid = msg["channelid"]