Skip to content

Add a 'disconnecting' event to access to socket.rooms upon disconnection #2332

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

Merged
merged 1 commit into from
Oct 6, 2016

Conversation

darrachequesne
Copy link
Member

As suggested there #1814 (all credits to @X-Coder)

socket.on('disconnecting', function(){
  var rooms = socket.rooms.slice();
  // socket.rooms should not be empty here (on 'disconnect' it is, because `leaveAll()` has already been called)
});

@nkzawa
Copy link
Contributor

nkzawa commented Dec 3, 2015

👍

Alternatively, we would be able to emit disconnect event before leaving rooms, in a similar way to the followings.

https://github.com/socketio/engine.io/blob/master/lib/socket.js#L296
https://github.com/socketio/engine.io-client/blob/master/lib/socket.js#L708

Though disconnecting event looks better to me too.

@rauchg
Copy link
Contributor

rauchg commented Dec 3, 2015

Let's resume this discussion after 1.4.0

@phutchins
Copy link

+1 on disconnecting. I have a branch that I was going to create a PR from that looks nearly identical to this... :)

I could also see renaming disconnect to disconnected but that would be a breaking change for a lot of folks... It would clear up what event you're actually catching however and might be worth it.

@kgunbin
Copy link

kgunbin commented Apr 14, 2016

+1

@enjikaka
Copy link

enjikaka commented Jun 6, 2016

Merge it!

@Alexandre-io
Copy link

+1

@Arcanorum
Copy link

+1 Cmon guys, make it happen...

@Walraz
Copy link

Walraz commented Jul 15, 2016

+1 This feature must exist now!

@slhrkc
Copy link

slhrkc commented Jul 18, 2016

+1

@gaurav21r
Copy link

gaurav21r commented Aug 4, 2016

+1 ! @rauchg I guess we are at 1.4.8 now! Can you please take a look at this? I guess this is a very common use case!

@darrachequesne darrachequesne force-pushed the patch-3 branch 2 times, most recently from cf1dab4 to 1c1e333 Compare August 5, 2016 20:49

Verified

This commit was signed with the committer’s verified signature.
masenf Masen Furer
@OmarElgabry
Copy link

+1

2 similar comments
@FrederikBolding
Copy link

+1

@AndreasGassmann
Copy link

+1

@darrachequesne darrachequesne merged commit 43d9a4b into socketio:master Oct 6, 2016
@darrachequesne darrachequesne deleted the patch-3 branch October 6, 2016 21:23
@enjikaka
Copy link

enjikaka commented Oct 7, 2016

Finally. Great! 💃

@X-Coder
Copy link

X-Coder commented Oct 7, 2016

Thank you, finally no more +1 mails in my inbox :-)
Did I miss the party? You merged it on the second birthday of the initial #1814 issue post.

dzad pushed a commit to dzad/socket.io that referenced this pull request May 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…disconnection (socketio#2332)
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

Successfully merging this pull request may close these issues.

None yet