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

210
Views
socket.io emitiendo a todos los clientes funciona, pero emitiendo a la sala no funciona

Cuando intento io.emit() , el mensaje se emite a todos, pero cuando intento io.to(room).emit() , el mensaje no se emite (en la tercera última línea del código).

Revisé manualmente los enchufes en la habitación y todos están presentes en la habitación correctamente. Pero el mensaje nunca se transmite.

 io.on('connection', (socket) => { socket.on("create game", async ( gameID, host ) => { socket.join(gameID); // some logic }) socket.on("join game", async ( gameID, user ) => { socket.join(gameID); // some logic io.to(gameID).emit("new user", user); }) });
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

¿Está su socket conectado a un espacio de nombres en particular? En mi proyecto tenía en el lado del cliente lo siguiente:

 const socket = io.connect("/play-online").

Entonces, para emitir a la habitación que creé para eso, tuve que hacer:

 io.of("/play-online").to(room.roomName).emit("move", move);
about 4 years ago · Juan Pablo Isaza Report

0

Pude arreglarlo usando socket.in(gameID).emit("new user", user); en cambio

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!