I want to create a bidirectional communication between a frontend and a backend using websockets. I am using Node.js ws. Using
wss.clients.forEach(function each(client) {
client.send("This is a message")
})
I am able to send a message to all clients with what I would call the "message" tag. Using Chrome Developer Tools, I can see that a ws packet with the ON_MESSAGE event is sent.
I would like to use a different kind of tag, however I can't find the documentation on how to do that, nor find anything on the internet that would explain a way of doing it. I tried things like the following, which did not work.
wss.clients.forEach(function each(client) {
client.emit("TAG", "This is a message")
})