INNER CODE UNIT · Python
on_message
dusty-nv/jetson-containers · packages/llm/local_llm/web/server.py:143
def on_message(self, payload, payload_size=None, msg_type=MESSAGE_JSON, msg_id=None, metadata=None, timestamp=None, path=None, **kwargs):
"""
Handler for recieved websocket messages. Implement this in a subclass to process messages,
otherwise msg_callback needs to be provided during initialization.
Parameters:
payload (dict|str|bytes) -- If this is a JSON message, will be a dict.
If this is a text message, will be a string.
If this is a binary message, will be a bytes array.
payload_size (int) -- size of the payload (in bytes)
msg_type (int) -- MESSAGE_JSON (0), MESSAGE_TEXT (1), MESSAGE_BINARY (2)
msg_id (int) -- the monotonically-increasing message ID number
metadata (str) -- message-specific string or other data
timestamp (int) -- time that the message was sent
path (str) -- if this is a file or image upload, the file path on the server
"""