I am currently working on a Javascript multiplayer game.
When users want to play, they enter a waiting room where they wait for players to play with.
It is stored in a SQL database this way :
I have a table named USER
with some data on the players, and another table named WAITINGROOM
which associates the id USERID
of the user waiting for a game with other infos.
When players leave the waiting room or close their browser, I delete the row with their id in table WAITINGROOM
.
But let's suppose the user loses his internet connection while looking for a game. How can I know he is offline so I can remove the row containing his id ?
The player is offline so it is definitely not client side I can deal with this. Maybe server side in PHP ? Or directly in the database using timeouts or something...