1

Are there any node.js module for managing users who are online?

By this I mean for a real-time application knowing who is available/connected. Sending messages between them, subscribing to events from different people, etc.

Thanks for any help.

fancy
  • 48,619
  • 62
  • 153
  • 231
  • http://stackoverflow.com/questions/3498005/user-authentication-libraries-for-node-js just set up socket.io to continue the connection – Lime Jan 08 '12 at 00:04
  • I would advising you add that to the Question, also just use mongodb + redis for the communications between servers – Lime Jan 08 '12 at 00:15
  • 1
    See http://stackoverflow.com/questions/8661758/advice-on-implementing-presence-for-a-web-site/8662707#8662707 – fent Jan 08 '12 at 04:30

2 Answers2

1

Sounds like something you could easily do on top of socket.io.

thejh
  • 44,854
  • 16
  • 96
  • 107
0

Integration of socket.io for real-time updates in Node.js is what you are searching for.

Sample Code:

io.on('connection',function(socket){  
    socket.on('update_list',function(data){
      //data.purpose;


      if((String(data.purpose.trim()))=='login'){
        var query="update user set online = ? where id = ?";
        con.query(String(query),['Y',data.id],function(err,rows){
         // var query="select * from user where id !='"+data.id+"'";
          var query="select * from user";
          con.query(String(query),function(err,rows){
            io.emit('logout update',JSON.stringify(rows));
          });
        });
      }else{
        var query="update user set online = ? where id = ?";
        con.query(String(query),['N',data.id],function(err,rows){
          //var query="select * from user where id !='"+data.id+"'";
          var query="select * from user";
          con.query(String(query),function(err,rows){
            io.emit('logout update',JSON.stringify(rows));
          });
        });
      }
    });
});  

You can find the proper documentation here: Online Users Node.js

Sunil Lama
  • 4,531
  • 1
  • 18
  • 46