question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

emitting to a room doesn't work for namespaced clients

See original GitHub issue

Failing

io.of('/foo').on('connection', function(client) {
  client.join('aaa');
  this.in('aaa').emit('goes to noone since packet endpoint is set to "/foo/aaa", instead of "/foo" and room: "aaa"')
})

Working

io.of('').on('connection', function(client) {
  client.join('aaa');
  this.in('aaa').emit('goes to aaa members since packet endpoint is set to "aaa"')
})

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
roymckenziecommented, Jun 11, 2018

I figured it out. Basically, when emitting to namespaced rooms you also need to define the namespace.

io.of('/chat').in( 'cool room' ).emit( 'new message' );
0reactions
alirezanassehcommented, Jun 9, 2018

Still not solved in 2018! socket.io 2.1.0, why?!

Read more comments on GitHub >

github_iconTop Results From Across the Web

socket.io emitting to all clients works, but emitting to room ...
When I try io.emit() , the message gets emitted to everyone but when I try io.to(room).emit() , the message doesn't get emitted (In...
Read more >
Rooms | Socket.IO
A room is an arbitrary channel that sockets can join and leave. It can be used to broadcast events to a subset of...
Read more >
Socket.io Namespaces and Rooms - LinkedIn
This emit signal is sent automatically by the client. Next I'll discuss the similarities and differences between Namespaces and Rooms, two ...
Read more >
Node.js Socket.io Namespaces, Rooms and Connections 02
And make sure to specify the namespace using the io.of method whenever you want to access the sockets or emit/add listeners. . As...
Read more >
Node.js Socket.io Namespaces, Rooms and Connections 02
Written Tutorial: https://go.ipenywis.com/ipenyb79ca--- Official Links----Official Website: http://ipenywis.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found