websocket: change 'all-channelids' to 'channelids'

Yeah, names are easier to work with when they're also valid identifiers.
This commit is contained in:
Brian Warner 2016-04-18 23:49:11 -07:00
parent f606207163
commit aa8f714a48
2 changed files with 9 additions and 9 deletions

View File

@ -27,8 +27,8 @@ from autobahn.twisted import websocket
# motd: all clients display message, then continue normally # motd: all clients display message, then continue normally
# error: all clients display mesage, then terminate with error # error: all clients display mesage, then terminate with error
# -> {type: "bind", appid:, side:} # -> {type: "bind", appid:, side:}
# -> {type: "list"} -> all-channelids # -> {type: "list"} -> channelids
# <- {type: "all-channelids", channelids: [int..]} # <- {type: "channelids", channelids: [int..]}
# -> {type: "allocate"} -> allocated # -> {type: "allocate"} -> allocated
# <- {type: "allocated", channelid: int} # <- {type: "allocated", channelid: int}
# -> {type: "claim", channelid: int} # -> {type: "claim", channelid: int}
@ -117,7 +117,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
def handle_list(self): def handle_list(self):
channelids = sorted(self._app.get_allocated()) channelids = sorted(self._app.get_allocated())
self.send("all-channelids", channelids=channelids) self.send("channelids", channelids=channelids)
def handle_allocate(self): def handle_allocate(self):
if self._channel: if self._channel:

View File

@ -525,7 +525,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
self.assertEqual(app.get_allocated(), set()) self.assertEqual(app.get_allocated(), set())
c1.send(u"list") c1.send(u"list")
msg = yield c1.next_event() msg = yield c1.next_event()
self.assertEqual(msg["type"], u"all-channelids") self.assertEqual(msg["type"], u"channelids")
self.assertEqual(msg["channelids"], []) self.assertEqual(msg["channelids"], [])
c1.send(u"allocate") c1.send(u"allocate")
@ -539,7 +539,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
c1.send(u"list") c1.send(u"list")
msg = yield c1.next_event() msg = yield c1.next_event()
self.assertEqual(msg["type"], u"all-channelids") self.assertEqual(msg["type"], u"channelids")
self.assertEqual(msg["channelids"], [cid]) self.assertEqual(msg["channelids"], [cid])
c1.send(u"deallocate") c1.send(u"deallocate")
@ -550,7 +550,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
c1.send(u"list") c1.send(u"list")
msg = yield c1.next_event() msg = yield c1.next_event()
self.assertEqual(msg["type"], u"all-channelids") self.assertEqual(msg["type"], u"channelids")
self.assertEqual(msg["channelids"], []) self.assertEqual(msg["channelids"], [])
@inlineCallbacks @inlineCallbacks
@ -585,12 +585,12 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
c1.send(u"list") c1.send(u"list")
msg = yield c1.next_event() msg = yield c1.next_event()
self.assertEqual(msg["type"], u"all-channelids") self.assertEqual(msg["type"], u"channelids")
self.assertEqual(msg["channelids"], [cid]) self.assertEqual(msg["channelids"], [cid])
c2.send(u"list") c2.send(u"list")
msg = yield c2.next_event() msg = yield c2.next_event()
self.assertEqual(msg["type"], u"all-channelids") self.assertEqual(msg["type"], u"channelids")
self.assertEqual(msg["channelids"], [cid]) self.assertEqual(msg["channelids"], [cid])
c1.send(u"deallocate") c1.send(u"deallocate")
@ -605,7 +605,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
c2.send(u"list") c2.send(u"list")
msg = yield c2.next_event() msg = yield c2.next_event()
self.assertEqual(msg["type"], u"all-channelids") self.assertEqual(msg["type"], u"channelids")
self.assertEqual(msg["channelids"], []) self.assertEqual(msg["channelids"], [])
@inlineCallbacks @inlineCallbacks