Saturday, 29 April 2017

Get a reference to the event listener from a middleware

Is there a way to get a reference to the event listener as in the following stub?

socket.on('login',login)

Could I get a reference to socket inside the function login?

// Login module

module.exports = ({username, password}, next) => {
   // How to refer socket here?
}

I cannot pass socket into the middleware, as the library I am using underneath doesn't recognize the third argument and I would not want to alter its regular behavior.



via Suhail Gupta

No comments:

Post a Comment