-
-
Notifications
You must be signed in to change notification settings - Fork 598
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
fix the order of triggered disconnect event #33
fix the order of triggered disconnect event #33
Conversation
Is there a specific problem you are trying to address with this change? The problem is that when the client disconnects there is no way to send events or actually do anything with that client connection, so it makes sense to remove it before calling the disconnect handler, since that client is unreachable anyway. |
well, I want the disconnected client to broadcast the news that it is disconnected and let certain client know that.
so in original order, I actually can not do anything related to socket in disconnect function. In your example
Actually, you just did simple print but how do I do something with sid? and I am curious about this part of code
why it call sorry my English.. I've already try hard to make my description clear. |
Your English is fine. :) I think the way disconnects are handled are very consistent. Basically what I tried to do is prevent is that you send an event from the disconnect handler to the user that got disconnected, as that will obviously fail. There are several ways to trigger a disconnection, and as I said above, they aren't handled in a consistent way. Examples:
This part I don't understand. What do you want to do? You do get the sid of the client. If you broadcast a message, all other clients will receive it, but not the disconnected one, since that one is already gone. Why is that a problem? |
the following code is part ot my project.
here the thing I want to do is the client to notify certain socket that it is disconnected ( in some situation like, user close the browser window or network connection lost. actually, it will fail if the user closed browser. I think the reason is
it will make sid be removed before it call the function
|
Can you show me the code for your |
I've tried it will work if the client invoke the following method
|
Okay, I do understand what you are trying to do now. You do not want to send anything to the disconnected client, but you want to know in which rooms that client was, so that you can broadcast something to the remaining clients in those rooms. Makes sense. I'm going to allow this change. I'll test it a little bit to make sure nothing is affected and if everything is all right I'll merge it. Thanks! |
Thanks :) By the way, it is so hard to communicate with others by second language. I will still improve my english in order to make my description more clear and understand what other people want to express. |
Yes, it's not easy, but you are doing a pretty good job. English is also a second language for me, by the way, but I have been speaking it for a long time. |
I think the order for triggering disconnect is wrong.