Why does the ws module accept different message events like socket.io?

socket.io:

socket.on("message",function(msg){ })
socket.on("privite",function(msg){})

allows ws to distinguish between different message events like this:

wss.on("connection", function connection(ws,t) {
ws.on("message1", function (message) {})
ws.on("message2", function (message) {})
....

the client uses HTML5 WebSocket, but the htms5 WebSocket event method can only send messages by ws.send (data), so how to define message events

Mar.20,2021

to customize a message protocol with message types, for example:

{
  type: "message_type",
  data: "message_data"
}

is then distributed according to type.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44fdc-44af4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44fdc-44af4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?