change 'list' protocol, make room for nameplate attributes
This commit is contained in:
parent
53bbcc33f6
commit
0ee56e12b0
|
@ -54,7 +54,7 @@ from .rendezvous import CrowdedError, SidedMessage
|
||||||
# -> {type: "bind", appid:, side:}
|
# -> {type: "bind", appid:, side:}
|
||||||
#
|
#
|
||||||
# -> {type: "list"} -> nameplates
|
# -> {type: "list"} -> nameplates
|
||||||
# <- {type: "nameplates", nameplates: [str..]}
|
# <- {type: "nameplates", nameplates: [{id: str,..},..]}
|
||||||
# -> {type: "allocate"} -> nameplate, mailbox
|
# -> {type: "allocate"} -> nameplate, mailbox
|
||||||
# <- {type: "allocated", nameplate: str}
|
# <- {type: "allocated", nameplate: str}
|
||||||
# -> {type: "claim", nameplate: str} -> mailbox
|
# -> {type: "claim", nameplate: str} -> mailbox
|
||||||
|
@ -152,7 +152,10 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
|
||||||
|
|
||||||
def handle_list(self):
|
def handle_list(self):
|
||||||
nameplate_ids = sorted(self._app.get_nameplate_ids())
|
nameplate_ids = sorted(self._app.get_nameplate_ids())
|
||||||
self.send("nameplates", nameplates=nameplate_ids)
|
# provide room to add nameplate attributes later (like which wordlist
|
||||||
|
# is used for each, maybe how many words)
|
||||||
|
nameplates = [{"id": nid} for nid in nameplate_ids]
|
||||||
|
self.send("nameplates", nameplates=nameplates)
|
||||||
|
|
||||||
def handle_allocate(self, server_rx):
|
def handle_allocate(self, server_rx):
|
||||||
if self._did_allocate:
|
if self._did_allocate:
|
||||||
|
|
|
@ -539,7 +539,12 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
|
||||||
c1.send(u"list")
|
c1.send(u"list")
|
||||||
m = yield c1.next_non_ack()
|
m = yield c1.next_non_ack()
|
||||||
self.assertEqual(m[u"type"], u"nameplates")
|
self.assertEqual(m[u"type"], u"nameplates")
|
||||||
self.assertEqual(set(m[u"nameplates"]), set([nameplate_id1, u"np2"]))
|
nids = set()
|
||||||
|
for n in m[u"nameplates"]:
|
||||||
|
self.assertEqual(type(n), dict)
|
||||||
|
self.assertEqual(list(n.keys()), [u"id"])
|
||||||
|
nids.add(n[u"id"])
|
||||||
|
self.assertEqual(nids, set([nameplate_id1, u"np2"]))
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_allocate(self):
|
def test_allocate(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user