Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
socket.io doesn't send to all room

I am using Socket.io with react to do a chat room, when a new user join the room i want to send an update to all clients.

const updateDiscussionClients = room => {
    let currentClients = RoomClients({room, io, connections})
    console.log(currentClients); // printing correct data
    console.log(io.sockets.adapter.rooms.get(room));
    socket.to(room).emit('clients_discussion', currentClients)
}

socket.on("join_discussion", (data) => {
    let room = 'room_' + data.id + data.name
    socket.join(room)
    updateDiscussionClients(room)
   
})

everything is working fine but the message received by old client, without the last one who

output of the logs:

[
  { name: 'Mohamad Zbib', id: '202100006' },
  { name: 'pu10', id: '10' }
]
Set(2) { 'pbKuaEdrfg7n83YyAAAD', '3QYOJCzlxxMOLquzAAAB' }

the event is received by pbKuaEdrfg7n83YyAAAD, but 3QYOJCzlxxMOLquzAAAB didn't receive it , he will receive if an update happened later

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

is 3QYOJCzlxxMOLquzAAAB sender of that event, which will not receive?

socket.to("room1").emit(/* ... */); will send to all in room except sender. io.in("room1").emit(/* ... */); will send to all in room

Check this cheat sheet for more info

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda