Skip to content

Difference between socket.join and io.adapter.remoteJoin? #171

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

Closed
robinclark opened this issue Jan 11, 2017 · 6 comments
Closed

Difference between socket.join and io.adapter.remoteJoin? #171

robinclark opened this issue Jan 11, 2017 · 6 comments

Comments

@robinclark
Copy link

I'm not sure I'm understanding the differences. Would someone mind clarifying?

@darrachequesne
Copy link
Member

@robinclark remoteJoin allow you to make a given socket join a room from another node.

Sample use-case: #125 (comment)

@darrachequesne
Copy link
Member

Do you have any suggestion to make the documentation clearer? Help is welcome!

@robinclark
Copy link
Author

I think my socket.io knowledge was just a bit lacking. I assumed that joining rooms normally across nodes would have worked without special handling. Nice addition!

@knoxcard
Copy link
Contributor

Here is a good question...do we need to run both socket.join() and socket.remoteJoin()?? or just socket.remoteJoin()?

@rodrigoreis22
Copy link

@knoxcard i have the same question, not sure if we should call both .join() and remotejoin().

@darrachequesne
Copy link
Member

socket.join() is when you have access to the socket object:

io.on('connect', socket => {
  socket.join('room1');
  
  socket.on('test', () => {
    socket.join('room2');
  });
});

adapter.remoteJoin() is when you don't have access to the socket object (in a multi server setup, for example):

io.of('/').adapter.remoteJoin(socketId, 'room1');

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

No branches or pull requests

4 participants