How to create game rooms that only one player can be in?
I know, I Can set Applications which stores if a player is in it or not.
But the problem comes when he closes the browser with [x], then I need to change the application value.
I thought to set a timer for 2 minutes and if the user does not refresh the page in this time then I know the Application should change value. there is a way to keep the timer running after he closed the browser?
I tried also with database Table and when a javascript happens it goes to a webmethod which changes the table values.
Some things that might help,
How to create a JavaScript function which happend ONLY when the browser is closed?
How to create the rooms in other way.
Here is the javascript I have
function DetectBrowserExit()
{
alert('Execute task which do you want before exit');
PageMethods.AppOff();
}
window.onbeforeunload = function () { DetectBrowserExit(); }
AppOff changes the table values,
but the script runs even if a user refreshed the page.
Any Ideas?
Thank you.