Server events

We will discuss some server-related events in this section.

connection

This event is fired when an initial connection with a client is established:

io.sockets.on('connection', function(socket) {})

Here, socket is used in further communication with the client.

message

The message event is emitted when a message sent with socket.send is received:

socket.on('message', function(<message>, <ack_callback>) {})

Here, message is the message sent and ack_callback is an optional acknowledgment function.

disconnect

This event is fired when the socket disconnects:

socket.on('disconnect', function() {})
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset