def on_message(self, message):
    'Called when a websocket client sends a message.'
    print('client sent: {!r}'.format(message))
    try:
        parsed_message = json.loads(message)
    except ValueError:
        print('Failed to parse message: {!r}'.format(message))
        return
    if ('message' in parsed_message):
        response = {'client': str(self.request.remote_ip), 'message': parsed_message['message']}
        m = json.dumps(response)
        self.write_message(m)
    else:
        print('message unhandled.')
Called when a websocket client sends a message.
def on_message(self, message):
    
    print('client sent: {!r}'.format(message))
    try:
        parsed_message = json.loads(message)
    except ValueError:
        print('Failed to parse message: {!r}'.format(message))
        return
    if ('message' in parsed_message):
        response = {'client': str(self.request.remote_ip), 'message': parsed_message['message']}
        m = json.dumps(response)
        self.write_message(m)
    else:
        print('message unhandled.')