I want to send authentication failed event back to client but I cannot think of how to do it. help please.
var interviewer = io.of('/interviewer');
// runs authorization and verify signature
interviewer.use(function(socket, next){
var status = myAuthFunction(data);
if(status){
next(); // it 'll trigger on('connection')
}else{
socket.emit('auth_error'); <<--- it does not emit 'auth_error'
}
});
// on Authentication success
interviewer.on('connection', function(socket){
socket.emit('server_started',{"status":1});
console.log('connected');
});
I know i cannot send 'auth_error' to client unless 'connection' is established. I am looking for proper solution.