htonus
htonus

Reputation: 649

How do namespaces actually work in Socket.IO?

With a single socket, I need to switch between two namespaces.

socket.on('ns1', function() {
  socket.join('ns1');
});

socket.on('ns2', function() {
  socket.join('ns2');
});

How would I disconnect from the namespace ns1 which I've already connected to and join the namespace ns2? And vice-versa?

Upvotes: 0

Views: 309

Answers (1)

htonus
htonus

Reputation: 649

The problem was solved with:

socket.leave('ns1');
socket.join('ns2');

and vice-versa.

Upvotes: 1

Related Questions