Is there a way to prevent the user to open the Meteor website in two tabs or browsers?
I am trying to create a card game in Meteor, and I would like to "catch" if the user tries to open the page in another tab or browser and just warn him that another client instance is already opened and maybe give him/her the option to logout in all instances, etc.
I've googled already, but no luck.
If the users are required to log in:
Connections collection, along with user id. (or the roomId to the profile itself, depending on your schema)Connections collectionIf the users do not have to log in:
Connections collection (along with user IP)Connections collectionAn example of using onConnection in the wild (note I don't disallow multiple connections, but that'd just be another 5 lines of code): https://github.com/mattkrick/react-tac-toe/blob/master/server/gameState.jsx#L13
The docs (ie how to capture ip address): http://docs.meteor.com/#/full/meteor_onconnection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With