A peer mesh and host handover

On 29 June 2026 the project added a peer-to-peer mesh test setup with latency simulation, host election and feature flags. The aim was a room that does not die when the player who started it closes the page.

Who is the host?

In an online game, one player's computer is the host: it decides the order in which things happen, so that everyone ends with the same game. That is simple until the host leaves, loses the connection or puts the phone to sleep. Then somebody else has to take over, and everyone has to agree on who.

Electing a new host

The mesh gives every player a link to every other player. When the host goes quiet for too long, the players elect a new host by a rule they all follow, and the new host continues the game from the state it has. A returning host steps down gracefully when a newer host is already running.

The rule also decides what happens to the seat of the player who left: it can be held for a short time so that someone who only lost their connection for a moment gets their character back.

Testing a bad network on a good one

The same commit added a latency simulation. It delays and drops messages on purpose, so that tests can reproduce a bad network without needing one. Many of the later online fixes were found by running scripted games under that simulated bad network and checking that every player ended in the same state.