Hello, I’m making a smartphone game and currently I work on a panel, that would look something like this:
Players online: 10
Players in queue: 4
Players in game: 40
I’ve got a database, that has 3 booleans: isOnline, isInQueue, isInGame. When player logs in, the php script is called and this script also sets this player’s boolean isOnline to true. But how could I possibly set this boolean to false when player quits the game? I was thinking about the coroutine call, which would call the php script, and this coroutine would start in the OnApplicationQuit(), but:
a) Would this coroutine end before the application quits?
b) I want to set isOnline to false even when player’s network connection drops, not only when they quit the app.
c) especially on iOS the app could be just suspended, not quit, hence the OnApplicationQuit would not be called
So, I was thinking about sending every 10 seconds a query to the server informing about player’s status. And when the server does not recieve any query from player who has isOnline or isInQueue or isInGame set to true within like 20 seconds, then these three variables would be set to false.
But how could I implement this? Or is there any better solution?
Thanks for any help in advance.