Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

90
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda