Cloudflare DevelopersCD
Cloudflare Developers3y ago
28 replies
Ottomated

Sure -

Sure -
The Durable Object handles websocket clients for a multiplayer game using a deterministic physics engine. The physics are executed on both the clients and the server. Serializing the physics world costs up to a few KB per player.

To join games, I have a lobbies table in D1 with a game_state column: 'waiting' | 'playing' | 'finished'. I need to set the game to the finished state when it's abandoned, so if the player rejoins the websocket later, it won't re-initialize the DO.

Because the transactional storage API is so expensive, I want to treat crashed games as permanently dead and show clients an error when they reconnect.
Was this page helpful?