Skip to content

Conversation

@sebamarynissen
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

New behavior

This PR adds the possibility to exclude specific socket ids when emitting messages:

io.except(id).emit("foo", "bar");
socket.broadcast.except(id).emit("foo", "bar");
socket.to("room").except(id).emit("foo", "bar");

In combination with socketio/socket.io-adapter#66 this will allow excluding all sockets in a specific room as well.

Other information (e.g. related issues)

See also socketio/socket.io-adapter#66 and socketio/socket.io-redis-emitter#92.

darrachequesne pushed a commit that referenced this pull request Mar 1, 2021
New syntax:

```
io.except("room1").emit(...);
io.to("room1").except("room2").emit(...);

socket.broadcast.except("room1").emit(...);
socket.to("room1").except("room2").emit(...);
```

Related:

- #3629
- #3657
@darrachequesne
Copy link
Member

Merged as 7de2e87. Thanks a lot 👍

This was referenced Mar 10, 2021
This was referenced Mar 11, 2021
dzad pushed a commit to dzad/socket.io that referenced this pull request May 29, 2023
New syntax:

```
io.except("room1").emit(...);
io.to("room1").except("room2").emit(...);

socket.broadcast.except("room1").emit(...);
socket.to("room1").except("room2").emit(...);
```

Related:

- socketio#3629
- socketio#3657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants