I am using socket.io and the Mean stack for a web app. I started the server for socket on 3006 port..
var http = require('http').createServer(app);
http.listen(3006);
var io = require('socket.io').listen(http);
Both of these seem to work on connection.
io.on('connection', function (socket) {
console.log('Socket succesfully connected with id: '+socket.id);
});
and...
io.sockets.on('connection', function (socket) {
console.log('Socket succesfully connected with id: '+socket.id);
});
What is the difference between io.on
and io.sockets.on
and which one should I use on first time connection..?
Though socket.on npm page uses io.on
why is it working for io.sockets.on