docstr: Callback that runs when a new message is received from a client See the
  chat_service README for the resultant message structure.
  
  Args:
      message_text: A stringified JSON object with a text or attachment key.
          `text` should contain a string message and `attachment` is a dict.
          See `WebsocketAgent.put_data` for more information about the
          attachment dict structure.
docstr_tok: ["Callback","that","runs","when","a","new","message","is","received","from","a","client","See","the","chat_service","README","for","the","resultant","message","structure",".","Args",":","message_text",":","A","stringified","JSON","object","with","a","text","or","attachment","key",".","`","text","`","should","contain","a","string","message","and","`","attachment","`","is","a","dict",".","See","`","WebsocketAgent.put_data","`","for","more","information","about","the","attachment","dict","structure","."]
code: def on_message(self, message_text):
      """
      Callback that runs when a new message is received from a client See the
      chat_service README for the resultant message structure.
  
      Args:
          message_text: A stringified JSON object with a text or attachment key.
              `text` should contain a string message and `attachment` is a dict.
              See `WebsocketAgent.put_data` for more information about the
              attachment dict structure.
      """
      logging.info(
          "websocket message from client: {}".format(message_text)
      )
      message = json.loads(message_text)
      message = {
          "text": message.get("text", ""),
          "payload": message.get("payload"),
          "sender": {"id": self.sid},
          "recipient": {"id": 0},
      }
      self.message_callback(message)
  
file_path: ParlAI/parlai/chat_service/services/websocket/sockets.py
imports: from typing import Dict, TypeVar
  from tornado.websocket import WebSocketHandler
  import uuid
  import logging
  import json
label_desc: Use image node_id 4 for calling the MessageSocketHandler obj's underlying member method code with example usage: obj.on_message(message_text) without return types