hello i'm trying to use socket io to get user notification from db. here is how i'm trying to get data and send them back to user
if(req.user) {
req.io.sockets.on('connection', function(socket){
setInterval(getNotf,1000)
function getNotf() {
User.findOne({email:req.user.email})
.then(user=>{
messages=(user.notifications);
console.log(messages)
socket.emit('output', messages);
});
}
});
} the problem with that way is that the message sent to all connected users.how can i send them only to the current user?