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

Add room create and delete events. #51

Closed
wants to merge 1 commit into from

Conversation

vincentwoo
Copy link

Also consolidate del and delAll functions a bit to be more symmetrical with add and addAll.

Previously, del would not remove the sids[id] entry even if it deleted the socket's last room.

Addresses socketio/socket.io#2897

Also consolidate `del` and `delAll` functions a bit to be more symmetrical with `add` and `addAll`.

Previously, `del` would not remove the `sids[id]` entry even if it deleted the socket's last room.
@darrachequesne
Copy link
Member

Thanks for the pull request.

Previously, del would not remove the sids[id] entry even if it deleted the socket's last room.

Actually, I'm not sure that makes sense here, since the socket would have to leave its own room too (since every socket joins the room designated by its id).

Regarding your use case, since the rooms are not shared between several adapters, you'll have to handle those cases:

server1.on('connection', (socket) => {
  socket.join('my-room'); // emit 'create-room' with 'my-room' 
});
// then, on another node
server2.on('connection', (socket) => {
  socket.join('my-room'); // emit 'create-room' with 'my-room' (again) 
});

@darrachequesne
Copy link
Member

Merged as 155fa63 and included in socket.io-adapter@2.1.0 & socket.io@3.1.0. Thanks!

@vincentwoo
Copy link
Author

whoa, four years later! trippy

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