Created
April 7, 2014 23:52
-
-
Save aurynn/10074760 to your computer and use it in GitHub Desktop.
Echo client lineReceived()
This file contains 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 lineReceived(self, msg): | |
try: | |
msg = json.loads(msg) | |
except json.JSONDecoderError: | |
print "Received a non-JSON message: %s" % msg | |
if "message" in msg: | |
print "<{from}> {message}".format(**msg) | |
elif "acknowledge" in msg: | |
if not msg["acknowledge"] in self.msgs: | |
print "We got a bad ack: {id}".format(msg["acknowledge"]) | |
return | |
id_ = msg["acknowledge"] | |
print id_ | |
self.msgs[id_]["deferred"].callback(self.msgs[id_]["msg"]) | |
del self.msgs[id_] | |
else: | |
print json.dumps(msg,indent=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment