I am implementing a chat client gui whith server-push functionality. The messages that will be sent will look like this:
yourMessage = {'name': 'David', 'text': 'hello world'}
I recieve a server-push by a call to the streamHandler
def streamHandler(incomingData):
if incomingData["event"] == "put":
if incomingData["path"] == "/":
if incomingData["data"] != None:
for key in incomingData["data"]:
message = incomingData["data"][key]
handleMessage(message)
else:
message = incomingData["data"]
handleMessage(message)
Then I have the function handleMessage that should retrieve the values of name and text:
def handleMessage(message):
for key in message.values():
printToMessages(key)
But now I get this Error: 'str' object has no attribute 'values' I have tried making message to dict but with no success, any ideas?
Perhaps the
messageparameter is ajsonstring.If so you can have: