From 390cd08b5305717ef0b67f36ecf372db5498af2c Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 20 May 2016 11:35:30 -0700 Subject: [PATCH] better command/response names: allocate+allocated, claim+claimed --- src/wormhole/server/rendezvous_websocket.py | 8 ++++---- src/wormhole/test/test_server.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wormhole/server/rendezvous_websocket.py b/src/wormhole/server/rendezvous_websocket.py index b0fb10a..4129400 100644 --- a/src/wormhole/server/rendezvous_websocket.py +++ b/src/wormhole/server/rendezvous_websocket.py @@ -56,9 +56,9 @@ from .rendezvous import CrowdedError # -> {type: "list"} -> nameplates # <- {type: "nameplates", nameplates: [str..]} # -> {type: "allocate"} -> nameplate, mailbox -# <- {type: "nameplate", nameplate: str} +# <- {type: "allocated", nameplate: str} # -> {type: "claim", nameplate: str} -> mailbox -# <- {type: "mailbox", mailbox: str} +# <- {type: "claimed", mailbox: str} # -> {type: "release"} # # -> {type: "open", mailbox: str} -> message @@ -160,7 +160,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): nameplate_id = self._app.allocate_nameplate(self._side, server_rx) assert isinstance(nameplate_id, type(u"")) self._did_allocate = True - self.send("nameplate", nameplate=nameplate_id) + self.send("allocated", nameplate=nameplate_id) def handle_claim(self, msg, server_rx): if "nameplate" not in msg: @@ -173,7 +173,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): server_rx) except CrowdedError: raise Error("crowded") - self.send("mailbox", mailbox=mailbox_id) + self.send("claimed", mailbox=mailbox_id) def handle_release(self, server_rx): if not self._nameplate_id: diff --git a/src/wormhole/test/test_server.py b/src/wormhole/test/test_server.py index 5289a98..d7377d1 100644 --- a/src/wormhole/test/test_server.py +++ b/src/wormhole/test/test_server.py @@ -544,7 +544,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase): app = self._rendezvous.get_app(u"appid") c1.send(u"allocate") m = yield c1.next_non_ack() - self.assertEqual(m[u"type"], u"nameplate") + self.assertEqual(m[u"type"], u"allocated") nameplate_id = m[u"nameplate"] nids = app.get_nameplate_ids() @@ -579,7 +579,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase): c1.send(u"claim", nameplate=u"np1") m = yield c1.next_non_ack() - self.assertEqual(m[u"type"], u"mailbox") + self.assertEqual(m[u"type"], u"claimed") mailbox_id = m[u"mailbox"] self.assertEqual(type(mailbox_id), type(u""))