socketio / socketio/socket.io-website

Emit cheatsheet: sending an event to all clients

Open
#192 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.