I built a notification system on my website. I've some kind of groups of members. When a member of a group posts something, the other members of the same group should be notified. Notifications appear when the user refreshes the page. However, the world is going in real-time. Googleing the issue recommended me Node.js (Not sure is the best way). I can now: create a server, connect to a database, querying the database, broad messages using socket.io to all connected clients...
But what I can't do/understand so far is to specify to which user(s) the message(notification) should be delivered.
Looking around SO comes with this way that looks what I want:
var socket = io.listen(server);
socket.on('connection', function(client) {
client.on('message', function(msg) {
broadcast(msg); // broadcast message to all clients
// OR
socket.clients[session_id].send(msg); // send message to one client
});
client.on('disconnect', function( ) {
console.log('Client Disconnected.');
});
});
I don't know what session_id is, is it the same as the session_id of the user created when he logs-in? Really got tired looking for some straight forward solutions, any help out will be strongly appreciated.