Start rendering and interacting with a remote game, reusing the app's own existing root rather than a second
one (a second documentDomItem() would claim the same real document.head/body the app's own root already has -
exactly the collision the server's own per-room roots had to avoid, see server/gameplay.ts). Every click/change
on the rendered tree is forwarded to the server instead of run locally (setForwardEvents) - the server's own
receiveForwardedEvent resolves and dispatches it, and the resulting gameUpdate is reconciled into this same tree.
Leaving the lobby's own listeners (presetListener, remoteListener, ...) alone is safe because the lobby's own
markup is no longer in the tree by the time this runs - clearChildren above already removed it.
Forwarding comes back off once the game actually ends (see isGameOver/stopForwarding) - the final-score
screen's own Play Again button needs to run as a real local listener, not a forwarded one - and back on
again for whatever the next gameUpdate turns out to be once Play Again succeeds and a fresh game starts.
Parameters
root: DomItemRoot
firstUpdate: RedactedBody
the redacted body already received (the game has already started by the time this is called)
Start rendering and interacting with a remote game, reusing the app's own existing root rather than a second one (a second documentDomItem() would claim the same real document.head/body the app's own root already has - exactly the collision the server's own per-room roots had to avoid, see server/gameplay.ts). Every click/change on the rendered tree is forwarded to the server instead of run locally (setForwardEvents) - the server's own receiveForwardedEvent resolves and dispatches it, and the resulting gameUpdate is reconciled into this same tree. Leaving the lobby's own listeners (presetListener, remoteListener, ...) alone is safe because the lobby's own markup is no longer in the tree by the time this runs - clearChildren above already removed it.
Forwarding comes back off once the game actually ends (see isGameOver/stopForwarding) - the final-score screen's own Play Again button needs to run as a real local listener, not a forwarded one - and back on again for whatever the next gameUpdate turns out to be once Play Again succeeds and a fresh game starts.