How to handle Safari back and forward maintaining socket connection? #4994
Unanswered
minchanhan
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Could you please check with the const socket = io({
closeOnBeforeunload: true
}); Reference: https://socket.io/docs/v4/client-options/#closeonbeforeunload |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a simple web game where the user automatically connects to a socket upon entering page, and they should disconnect when they close the tab/window, or move back/forward in browser. Each of the listed methods trigger the
beforeunload
event in my React app, except for Safari's back/forward buttons.I'm not sure how to handle socket disconnects then, because if a user "leaves", it should trigger an event for all users in the same room as them. How can I make a user disconnect from the socket and "leave" the room even if they exit through Safari back/forward buttons?
Beta Was this translation helpful? Give feedback.
All reactions