Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

login.bind({socket: socket}) Then in login function use this.socket

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!