-
Notifications
You must be signed in to change notification settings - Fork 10
socket-io: Closing Browser Tab and OnDisconnect Event #49
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
Comments
This library is a server implementation of the SocketIO library. It's not a client which is what will run the the browser. So closing a browser shouldn't trigger any events in this library. Or I may be missing something. Can you point out where in the js version of the SocketIO library there is a OnDisconnect event triggered when the browser is closed, so that I can see what's done to emulate it? |
I see, because I used a different go library before that has this feature, namely: https://github.com/googollee/go-socket.io. Sadly this library uses an outdated version of socket.io server which won't work with our front-end technologies. Here's the documentation with regards to the disconnect trigger:
For now I just forked the library and modified some stuff to have this mechanism work. In my case, I just modified that if the connection timed out it will trigger the onDisconnect event provided the said connection hasn't been disconnected manually by the client. |
Ah, I see. I missed that functionality in the documentation! I saw your fork... I think there could be a race condition around the setting of the disconnect boolean and calling disconnect(), but I'm not positive. (in transport/transport.go:80 and transport/transport.go:84 in commit fdc1a5a) Would you consider adding a test around your change and submitting a Pull Request? This would be a good addition to the library. If you don't feel comfortable or have the time, please let me know, and I'll add some equivalent code. |
I will add this functionality in, over the next week. Thanks for reporting it! |
Hello, Thank you for the project. Just wanted to add that this would be a great thing to have. I did something on my side based on what @nmilallos97 already did in order to trigger the |
Hi @njones, is this something that you're still planning to include? Would really like to have this functionality. |
Propagate the Projected completion: Jan. 29, 2024 |
Upon exploring the library, I noticed that the OnDisconnect event does not trigger when closing the browser tab of an active socket connection.
However calling
socket.disconnect()
on client side triggers the OnDisconnect event.The text was updated successfully, but these errors were encountered: