I've been trying for some days to develop a real-time notification web app using node.js
and the socket.io
module.
WHAT I HAVE DONE
I have two parts.1) Admins and 2) Users.
So I have initialized two different namespaces on the client side.
Fo example: var socket = io();
for Admins and var socket = io('/Users');
for Users.The time a User sends a message, message goes to ALL of the Admins (1st step made). I am using this command to emit: nsp3.emit('chat message', obj);
.nsp3 is var nsp3 = io.of('/Admins');
on the server and obj is a json
structure.
WHAT I WANT TO ACCOMPLISH
When a message is sended by some User then the server receives the request, makes a SELECT
query to db table based on some criteria and emit the message to a part of Admins who meet these criteria.
Which is the best way to do this?