socketio / socketio/socket.io-website
Emit cheatsheet: sending an event to all clients
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 342
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
The Emit cheatsheet page says that it's possible to send an event to all clients like this:
// sending to all connected clients
io.emit('an event sent to all connected clients');
However, according to this documentation page, io is an alias for io.sockets (source code; it seems this isn't mentioned in the server API documentation) which itself (according to this page and source code) is an alias for io.of('/') (assuming io is a Socket.IO server). I tested this, and io.emit(...) indeed behaves just like io.of('/').emit(...).
It seems that sending an event to all clients in all namespaces is not even possible (except if you manually send it to every namespace you're interested in with multiple io.of(...).emit(...) calls).
The following example from the cheatsheet is also likely wrong, but I haven't tested it:
// sending to all clients on this node (when using multiple nodes)
io.local.emit('hi', 'my lovely babies');
My guess is that it will send an event to every cilent on the default namespace of the current node (source code: it only sets a modifier on the default namespace).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Emit cheatsheet and compare its examples with the linked Default namespace and Server API pages. Check the cited locations in lib/index.ts to verify the namespace scope of io.emit and io.local. Done means the documentation accurately describes their scope and corrects any misleading examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100