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

86
Views
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 answers
Answer question

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 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!