When I disconnect from a Socket.IO server, the socket has no rooms in the clientSocket.rooms
array. How can I get the rooms he has and will be disconnected from. Does the disconnect from rooms happen before the disconnect event on the socket and is there a way to get the rooms?
Asked
Active
Viewed 205 times
1

mscdex
- 104,356
- 15
- 192
- 153

Jānis Gruzis
- 905
- 1
- 10
- 25
-
Ok, only i could do was creating my own join and leave methods to follow last status of rooms for each socket. – Jānis Gruzis Oct 31 '14 at 18:25
-
What did you do if the client is disconnected because of a closed app/browser window? – Noah B Apr 26 '15 at 05:20
-
@NoahB i did the same thing as in first comment. It doesnt matter how client disconnects from server. Disconnect works the same. – Jānis Gruzis Apr 26 '15 at 19:51
-
So you customized the methods in the socket.io library code? (Otherwise, how were your methods called before the disconnect if the browser is just closed?) – Noah B Apr 26 '15 at 20:24
-
@NoahB you call them on callbacks. You should not probably override the methods. Have rooms = {}. On connect callback set rooms[socketRoom].push(socket) and on disconnect callback rooms[socketRoom].pop(socket). Js isnt 100% perfect but this is just to present idea. – Jānis Gruzis Apr 26 '15 at 20:46