Answer the question
In order to leave comments, you need to log in
How to replace the $emit method (which used to be in socket.io)?
Example: otherModule.js
exports.post = function (req, res, next) {
var sid = req.session.id;
var io = req.app.get('io');
req.session.destroy(function (err) {
io.sockets.$emit('session:reload', sid);
// ...
res.redirect('/');
}
};
io.sockets.on('session:reload', function(sid) {
// ...
});
Answer the question
In order to leave comments, you need to log in
Found I don't think this is the best way, but correct me if it's wrong
in socket.js
io.on("sessreload",function(sid){
//some code
});
exports.post = function(req, res,next){
var sid = req.session.id;
var io = req.app.get("io");
req.session.destroy(function(err){
io.sockets._events.sessreload(sid);
if(err) next(err);
res.redirect('/');
});
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question