-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Proposed Feature: Batch join and leave #2466
Comments
+1 |
+1 my users joins a room for each "friend" to use it as a private chat. 100 friends = 100 socket.join |
What is wrong with looping through a list of rooms? Unless I am missing something shouldn't the below snippet of code achieve the same thing? var rooms = [ 'roomOne', 'roomTwo', 'roomThree' ];
for (room in rooms) {
socket.join(rooms[room]);
} or var rooms = [ 'roomOne', 'roomTwo', 'roomThree' ]
for (i = 0; i < rooms.length; i++) {
socket.join(rooms[i]);
} |
@baconface If you use redis/clusters can be a huge network traffic improvment in some cases |
This is the time breakdown for a new socket connecting to my socket.io service in which the connected user is in a number of different channels for various chat rooms they are a member of: 70% of the initial connection response time is being spent sending on average 25 different |
Gotcha. 👍 |
Gotcha. 👍 |
@nathanpeck ! May you help me? Please give me a idea or a suggestion. I need to solve that problem for my project. |
That is a great idea for improvement. |
Depending on the underlying adapter being used it may be much more efficient to join multiple rooms in one batch operation, rather than joining rooms one a time.
For example if you imagine a Slack like app where each user is in many channels, and each channel has its own socket.io room then on initial connection to the socket.io server you may need to do
socket.join()
for each channel the user is in. If the user is in many channels it would be much more efficient if it was possible to do a batch join operation likesocket.join(['roomOne', 'roomTwo', 'roomThree'])
.This would be well suited for the redis adapter for example, as the redis SUBSCRIBE operation supports multiple channels in one op.
Thoughts? Does anyone else like/need this feature?
I could easily create my own private fork with this simple feature for my own personal usage, but wanted to see if there was more general interest in adding such a feature to the mainline.
The text was updated successfully, but these errors were encountered: