p-society / gc-server

Stay updated in real-time and engage with the thrill of the game like never before.[WIP]
Apache License 2.0
3 stars 6 forks source link

[FEAT]: Prevent opening in multiple tabs #7

Open majorbruteforce opened 7 months ago

majorbruteforce commented 7 months ago

A functionality can be built to prevent the app from being opened in multiple tabs like WhatsApp web does. This is to cater the limitation that SSE can have only 6 concurrent tabs open at a time and also reduce connections per user with the server.

AnirudhParida commented 7 months ago

Server-side solution: You can use a session-based mechanism on the server side, which will only allow one session per user. If the user tries to open the same site in another tab, the server will detect the existing session and redirect the user to the original tab.

JavaScript: You can use JavaScript to detect when a new tab is opened with the same URL and redirect the user back to the original tab.

zakhaev26 commented 7 months ago

Nice techniques! Client side JS would be better as it would respond fast , and UX will be good Tracking Sessions in server might not be a scalable solution as it will store the session data in the RAM and would bloat the server mem if many clients use the app + It would take some time in the req<-->res cycle