First working test version of oob support in the websocket client.

This commit is contained in:
Griatch 2014-06-25 23:35:21 +02:00
parent a9cf081494
commit ca1e36da5f
5 changed files with 48 additions and 26 deletions

View file

@ -73,7 +73,7 @@ class WebSocketProtocol(Protocol, Session):
prefix.
OOB - This is an Out-of-band instruction. If so,
the remaining string should be a json-packed
string on the form {oobfuncname: [[args], {kwargs}], ...}
string on the form {oobfuncname: [args, ], ...}
any other prefix (or lack of prefix) is considered
plain text data, to be treated like a game
input command.
@ -82,10 +82,8 @@ class WebSocketProtocol(Protocol, Session):
string = string[3:]
try:
oobdata = json.loads(string)
for (key, argstuple) in oobdata.items():
args = argstuple[0] if argstuple else []
kwargs = argstuple[1] if len(argstuple) > 1 else {}
self.data_in(text=None, oob=(key, args, kwargs))
for (key, args) in oobdata.items():
self.data_in(text=None, oob=(key, args))
except Exception:
log_trace("Websocket malformed OOB request: %s" % string)
else: