rdv_ws: deliver "server_tx", not "sent"
Update twisted/transcribe.py to accept it, update tests.
This commit is contained in:
parent
d2dfc325d8
commit
8a80242532
|
@ -161,7 +161,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
|
||||||
|
|
||||||
def send(self, mtype, **kwargs):
|
def send(self, mtype, **kwargs):
|
||||||
kwargs["type"] = mtype
|
kwargs["type"] = mtype
|
||||||
kwargs["sent"] = time.time()
|
kwargs["server_tx"] = time.time()
|
||||||
payload = json.dumps(kwargs).encode("utf-8")
|
payload = json.dumps(kwargs).encode("utf-8")
|
||||||
self.sendMessage(payload, False)
|
self.sendMessage(payload, False)
|
||||||
|
|
||||||
|
|
|
@ -685,8 +685,8 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
|
||||||
self.assertEqual(msg["type"], "message")
|
self.assertEqual(msg["type"], "message")
|
||||||
self.assertEqual(strip_message(msg["message"]),
|
self.assertEqual(strip_message(msg["message"]),
|
||||||
{"phase": "1", "body": "msg1A"})
|
{"phase": "1", "body": "msg1A"})
|
||||||
self.assertIn("sent", msg)
|
self.assertIn("server_tx", msg)
|
||||||
self.assertIsInstance(msg["sent"], float)
|
self.assertIsInstance(msg["server_tx"], float)
|
||||||
|
|
||||||
c1.send(u"add", phase="1", body="msg1B")
|
c1.send(u"add", phase="1", body="msg1B")
|
||||||
c1.send(u"add", phase="2", body="msg2A")
|
c1.send(u"add", phase="2", body="msg2A")
|
||||||
|
|
|
@ -140,7 +140,7 @@ class Wormhole:
|
||||||
return meth(msg)
|
return meth(msg)
|
||||||
|
|
||||||
def _ws_handle_welcome(self, 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"]
|
welcome = msg["welcome"]
|
||||||
if ("motd" in welcome and
|
if ("motd" in welcome and
|
||||||
not self.motd_displayed):
|
not self.motd_displayed):
|
||||||
|
@ -191,7 +191,7 @@ class Wormhole:
|
||||||
self._wakeup()
|
self._wakeup()
|
||||||
|
|
||||||
def _ws_handle_error(self, msg):
|
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"]),
|
err = ServerError("%s: %s" % (msg["error"], msg["orig"]),
|
||||||
self._ws_url)
|
self._ws_url)
|
||||||
return self._signal_error(err)
|
return self._signal_error(err)
|
||||||
|
@ -224,7 +224,7 @@ class Wormhole:
|
||||||
returnValue(code)
|
returnValue(code)
|
||||||
|
|
||||||
def _ws_handle_allocated(self, msg):
|
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:
|
if self._channelid is not None:
|
||||||
return self._signal_error("got duplicate channelid")
|
return self._signal_error("got duplicate channelid")
|
||||||
self._channelid = msg["channelid"]
|
self._channelid = msg["channelid"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user