End-of-game timing information is inconsistent with event timestamps
See original GitHub issueWhen a game is ended, the final timer value (games/${gameId}/endedAt
) is usually 5-50ms higher than the timestamp of the last game event (gameData/${gameId}/events/${eventId}/time
). This is because the client takes an extra round-trip to finalize that a game has finished.
Example
In the image below, the last event has timestamp 02:35.52, but the final timer stops at 02:35.55. There’s a delay of around 30ms after the last set, before the game actually ends, and the database is updated.
Fixing
One solution involves adding an HTTPS-callable serverless function to end the game, which when called, checks if the game is actually finished (and that the user is authenticated), then sets the endedAt
key to be the time of the last valid event, rather than simply the current time. This would resolve the visible discrepancy in timestamps.
This is a good opportunity to learn about serverless functions, realtime database permissions, and Set with Friends’s architecture. Please contact me if interested.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
It seems I need additional perms to be able to deploy any functions. Let me know if this seems feasible or if something else is causing this error!
Created a PR let me know if there is anything wrong/that you want changed!