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

258
Views
usando socket cómo transmitir mensajes a usuarios específicos que tienen role_id = 1

Usando Socket y node express, quiero enviar un mensaje a todos los usuarios que tienen role_id 1, pero cada vez que transmito un mensaje, todos los usuarios lo reciben.

 // let suppose this is message let Message = 'hello all users' //socket code socket.emit('message', Message); //but i want to send message to below users. // I am not a good programmer and i am new to socket. //during user login time i return this if (login == true) { user.status = 'Online'; }

el estado no tiene nada con el mensaje. solo está actualizando el estado del usuario

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

//first of all join user to room if has role id 1 //during user login time i return this let role_room_id = 1; if (login == true) { user.status = 'Online'; socket.join(role_room_id); } ///then emit message in that room socket.broadcast.to(role_room_id).emit('message', Message);
about 4 years ago · Juan Pablo Isaza 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!