I hope you can help me, because I want to know this and I have not found anything useful in the searches. Basically what I want is to do as a listener if that is how it is said, waiting for another function to react (or make a callback, I think), and when you receive information, that is activated. I have a socket, which receives information, and I want it to react when I notify the on chat event and send it parameters as well. I do not know if I explain myself well, but I'll leave a few lines of code as an example:
connection.on("Chat"){
alert(evento.parámetro)
}