Created
March 14, 2017 20:59
-
-
Save sammachin/25512bfeaf355e81c572d9599f7d8100 to your computer and use it in GitHub Desktop.
WTF JSON?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ptt_btn.onmousedown = function(e){ | |
ptt=true; | |
document.getElementById("tx").innerHTML=status_tx; | |
if(ws.readyState == ws.OPEN) { | |
var evt = '{"event": "ptt_on"}'; | |
ws.send(JSON.stringify(evt)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUG "{\"event\": \"ptt_on\"}" | |
DEBUG {"event": "ptt_on"} | |
ERROR Uncaught exception in /socket | |
Traceback (most recent call last): | |
File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 322, in wrapper | |
return callback(*args, **kwargs) | |
File "./server.py", line 140, in on_message | |
if data["event"] == "connect": | |
TypeError: string indices must be integers | |
INFO client disconnected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_message(self, message): | |
# Check if message is Binary or Text | |
if type(message) == str: | |
#Processing of Binary Messages | |
else: | |
debug(message) | |
data = json.loads(message) | |
debug(data) | |
if data["event"] == "connect": | |
self.id = data['id'] | |
conns[self.id] = self | |
elif data["event"] == "ptt_off": | |
self.frame_buffer.process(self.id) | |
else: | |
info("Unknown event: {}".format(data)) | |
self.write_message('ok') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment