Do you have to socket.leave() a room on disconnect?

654 views
Skip to first unread message

BrianGruber

unread,
Nov 17, 2011, 2:33:03 PM11/17/11
to Socket.IO
Do you have to manually call socket.leave("room name") when
onDisconnect fires, or does the disconnect automatically remove a user
from a room? Concerned about memory leaks.

Pavel Sakun

unread,
Nov 18, 2011, 7:09:56 AM11/18/11
to sock...@googlegroups.com
What about something like:
socket.on("disconnect" function() {
   this.leave("room");
});

It's not real code, just to explain my idea.
--
Best regards.
Pavel.

BrianGruber

unread,
Nov 18, 2011, 9:39:15 AM11/18/11
to Socket.IO
That's what I'm doing now, but I also have to keep a running tab of
any other rooms the user is in. I'm just curious if the library itself
does this somewhere internally, otherwise I'm doing double the work.

- Brian

On Nov 18, 6:09 am, Pavel Sakun <snaky...@gmail.com> wrote:
> What about something like:
> socket.on("disconnect" function() {
>    this.leave("room");
>
> });
>
> It's not real code, just to explain my idea.
>

yildiray mutlu

unread,
Nov 17, 2011, 3:41:16 PM11/17/11
to sock...@googlegroups.com


When user close the window, it disconnect from server little bit later. Haven't removed it manually.

Reply all
Reply to author
Forward
0 new messages