on
Adds a socket event listener.
server.on(event, handler)
Adds a socket event listener.
server.on("notifications", function(data, ackFn){
console.log("Received " + data);
ackFn("Acknowledged, thank you");
});
Parameters
- event
{string}
:The name of the socket event to listen for.
- handler
{SocketEventListener()}
:The handler that will be executed to handle the socket event.
server.on(eventsObject)
A short hand method to add multiple event listeners.
server.on({
"news": handleNews,
"tweets": handleTweets,
"users": handleUsers
});
Parameters
- eventsObject
{object}
: