-
My React application has a home page where a user can create a “room” and connect to a socket. The /game-page is wrapped in a SocketContext component, which connects to the Socket.IO server and performs the handshake. Once inside /game-page, the UI handles triggering the create room event, and if successful, it displays the room UI. ⸻ Desktop behaviour This part works fine. ⸻ Mobile behaviour On mobile, the flow is different: Here’s where the problem occurs:
⸻ My confusion I’m not sure if this behaviour is caused by a mistake in my event/architecture design or if it’s just how browsers handle backgrounded tabs and sockets on mobile. One potential workaround I considered is: I’m not sure if this would introduce edge cases, and I’d like to find a more robust solution. Another idea was.. In the socket.io.on('reconnect', (attempt) => { emit another event which checks if user/socket is within any room. If not kick him.. ⸻ Looking forward to hear anyidea and how generally you would solve this scenario. Thanks! Socket connection settings:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I decided to do a check after the
|
Beta Was this translation helpful? Give feedback.
I decided to do a check after the
reconnect
event, seems working fine :)