Skip to content

Allow to join several rooms at once#2879

Merged
darrachequesne merged 1 commit intosocketio:masterfrom
darrachequesne:feat/addall
Feb 26, 2017
Merged

Allow to join several rooms at once#2879
darrachequesne merged 1 commit intosocketio:masterfrom
darrachequesne:feat/addall

Conversation

@darrachequesne
Copy link
Member

The kind of change this PR does introduce

  • a new feature

New behaviour

Enable the following:
socket.join(['room1', 'room2']);

Closes #2466, closes #2877

@darrachequesne darrachequesne merged commit 01a4623 into socketio:master Feb 26, 2017
@NguyenTungs
Copy link

@darrachequesne
Thanks a lot. So great feature that.

@NguyenTungs
Copy link

NguyenTungs commented Feb 27, 2017

@darrachequesne .
I've tried, and upgrade version 1.7.3

    "socket.io": "^1.7.3",

But that feature still not working.

Code here:

    socket.join(['tungns1', 'tungns2', 'tungns3']); // client join

But i changed :

   for(var i = 1, length1 = 4; i < length1; i++){
             console.log('tungns'+i);
             socket.join('tungns'+i);
    }

Then working.
So Could you review again that feature? Thanks a lot.

@darrachequesne
Copy link
Member Author

Yep, it's not released yet.

@angel1st
Copy link

@darrachequesne - since we have now ability to join multiple rooms at once, shouldn't be nice to have the same for sending a message to multiple rooms?
I know, I can manage this like that:

['room1', 'room2', 'room3'].forEach(room => {
  // send message to all clients in the room, but the sender
  socket.broadcast.to(room).emit('message', 'nice game');
});

but I guess something like:

socket.broadcast.to(['room1', 'room2', 'room3']).emit('message', 'nice game');

will be more handy.

@darrachequesne darrachequesne deleted the feat/addall branch August 21, 2018 11:49
@darrachequesne
Copy link
Member Author

@angel1st great idea! Could you please open a PR for that?

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.

[Question] - How to client can join two room the same time? Proposed Feature: Batch join and leave

3 participants