This is post-event Route . when a user Posts an event then that event should be sent to all its follower! I have maintained the Follower Array for that.
How to that using Socket.io ????
module.exports.postEvent = (req,res) => {
Events.saveEvent(req.body , (err,saveEvent)=>{
var response = {
status : 500,
message : err
};
var id = req.userId;
if(err){
res.status(response.status)
.json(response.message);
}else {
// find the data of user from token and
user.getuserbyname(id ,(err,user)=>{
if(err){
res.status(response.status)
.json(response.message);
}else{
// send to all user subscribers via socket.io
async.each(user.followers ,(id , callback)=>{
what will be the code here???
})
}
})
}
})
};