Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to using send message to array rooms #3048

Closed
thandonguocmo2020 opened this issue Sep 9, 2017 · 1 comment
Closed

how to using send message to array rooms #3048

thandonguocmo2020 opened this issue Sep 9, 2017 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@thandonguocmo2020
Copy link

my rooms :

var rooms = [ObjectId1,ObjectId2,...n ObjectId); // 10 item

socket.join(rooms);

how to send it looks so

socket.to(rooms).emit("send-notitication", data)

my help !

@darrachequesne darrachequesne added the enhancement New feature or request label Feb 19, 2021
darrachequesne added a commit that referenced this issue Mar 1, 2021
In some cases it is necessary to pass an array of rooms instead of a single room.

New syntax:

```
io.to(["room1", "room2"]).except(["room3"]).emit(...);

socket.to(["room1", "room2"]).except(["room3"]).emit(...);
```

Related: #3048
@darrachequesne
Copy link
Member

This feature was implemented by 085d1de and included in socket.io@4.0.0.

Syntax:

io.to(["room1", "room2", "room3"]).emit(/* ... */);

socket.to(["room1", "room2", "room3"]).emit(/* ... */);

Documentation: https://socket.io/docs/v3/migrating-from-3-x-to-4-0/#Allow-to-pass-an-arrow-to-io-to

@darrachequesne darrachequesne added this to the 4.0.0 milestone Mar 11, 2021
dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
In some cases it is necessary to pass an array of rooms instead of a single room.

New syntax:

```
io.to(["room1", "room2"]).except(["room3"]).emit(...);

socket.to(["room1", "room2"]).except(["room3"]).emit(...);
```

Related: socketio#3048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants