Understand the WebSocket message wrapper format
mainAll messages exchanged between the client and the server via WebSockets follow a standardized wrapper structure. Every message must include a type string to identify the message purpose and a payload containing the actual data associated with that type.
{
"type": string,
"payload": any // based on type
}