better command/response names: allocate+allocated, claim+claimed
This commit is contained in:
parent
6c5b517ad1
commit
390cd08b53
|
@ -56,9 +56,9 @@ from .rendezvous import CrowdedError
|
||||||
# -> {type: "list"} -> nameplates
|
# -> {type: "list"} -> nameplates
|
||||||
# <- {type: "nameplates", nameplates: [str..]}
|
# <- {type: "nameplates", nameplates: [str..]}
|
||||||
# -> {type: "allocate"} -> nameplate, mailbox
|
# -> {type: "allocate"} -> nameplate, mailbox
|
||||||
# <- {type: "nameplate", nameplate: str}
|
# <- {type: "allocated", nameplate: str}
|
||||||
# -> {type: "claim", nameplate: str} -> mailbox
|
# -> {type: "claim", nameplate: str} -> mailbox
|
||||||
# <- {type: "mailbox", mailbox: str}
|
# <- {type: "claimed", mailbox: str}
|
||||||
# -> {type: "release"}
|
# -> {type: "release"}
|
||||||
#
|
#
|
||||||
# -> {type: "open", mailbox: str} -> message
|
# -> {type: "open", mailbox: str} -> message
|
||||||
|
@ -160,7 +160,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
|
||||||
nameplate_id = self._app.allocate_nameplate(self._side, server_rx)
|
nameplate_id = self._app.allocate_nameplate(self._side, server_rx)
|
||||||
assert isinstance(nameplate_id, type(u""))
|
assert isinstance(nameplate_id, type(u""))
|
||||||
self._did_allocate = True
|
self._did_allocate = True
|
||||||
self.send("nameplate", nameplate=nameplate_id)
|
self.send("allocated", nameplate=nameplate_id)
|
||||||
|
|
||||||
def handle_claim(self, msg, server_rx):
|
def handle_claim(self, msg, server_rx):
|
||||||
if "nameplate" not in msg:
|
if "nameplate" not in msg:
|
||||||
|
@ -173,7 +173,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
|
||||||
server_rx)
|
server_rx)
|
||||||
except CrowdedError:
|
except CrowdedError:
|
||||||
raise Error("crowded")
|
raise Error("crowded")
|
||||||
self.send("mailbox", mailbox=mailbox_id)
|
self.send("claimed", mailbox=mailbox_id)
|
||||||
|
|
||||||
def handle_release(self, server_rx):
|
def handle_release(self, server_rx):
|
||||||
if not self._nameplate_id:
|
if not self._nameplate_id:
|
||||||
|
|
|
@ -544,7 +544,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
|
||||||
app = self._rendezvous.get_app(u"appid")
|
app = self._rendezvous.get_app(u"appid")
|
||||||
c1.send(u"allocate")
|
c1.send(u"allocate")
|
||||||
m = yield c1.next_non_ack()
|
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"]
|
nameplate_id = m[u"nameplate"]
|
||||||
|
|
||||||
nids = app.get_nameplate_ids()
|
nids = app.get_nameplate_ids()
|
||||||
|
@ -579,7 +579,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
|
||||||
|
|
||||||
c1.send(u"claim", nameplate=u"np1")
|
c1.send(u"claim", nameplate=u"np1")
|
||||||
m = yield c1.next_non_ack()
|
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"]
|
mailbox_id = m[u"mailbox"]
|
||||||
self.assertEqual(type(mailbox_id), type(u""))
|
self.assertEqual(type(mailbox_id), type(u""))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user