1/* Upon disconnection, sockets leave all the channels they were part of
2automatically, and no special teardown is needed on your part.
3
4You can fetch the rooms the Socket was in by listening to the
5disconnecting event: */
6
7io.on('connection', socket => {
8 socket.on('disconnecting', () => {
9 console.log(socket.rooms); // the Set contains at least the socket ID
10 });
11
12 socket.on('disconnect', () => {
13 // socket.rooms.size === 0
14 });
15});