Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs api to logged in users count on an application

var io = require('socket.io').listen(8080);
var count = 0

io.sockets.on('connection', function(socket) {
    count++;
    io.sockets.emit('message', { count: count });

    socket.on('disconnect', function(){
        count--;
        io.sockets.emit('message', { count: count });
    })
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nodejs #api #logged #users #count #application
ADD COMMENT
Topic
Name
2+7 =