I am trying to create a game where when the player closes his window the mongo database is changed to “player1 is inactive”.
This is the code I have in main.js:
window.addEventListener('beforeunload', function (e) {
Games.update({_id : myGuy},{$set:{active : 0}});
// Cancel the event
e.preventDefault();
// Chrome requires returnValue to be set
e.returnValue = '';
});
It works sporadically in Firefox and pretty much never in Chrome. ?I’m thinking maybe meteor might change the local mini mongo but doesn’t know to change the mongo on the server? (Just a thought.)