jonnify·bcs /bcs/codemojex/the-live-surface/channels-and-pubsub

B7.6.2 · dive 2 of 3 · module B7.6

Channels and PubSub.

Live updates ride a WebSocket channel fed by PubSub: the score worker publishes a scored event, every channel on that game forwards it, and the mode decides — a live room pushes at once, a blind room stays silent until the close.

The worker broadcasting on PubSub, a game channel forwarding it, and live versus blind. Select a part.
score workerbroadcasts on PubSub a game channelforwards the eventresult and board move live roompushes at onceblind roomsilent until close
readout · Select a part. The score worker publishes a scored event on PubSub; a game channel forwards it so the result and board move arrive at once; a live room pushes, a blind room stays silent until the close.
§1

The idea

codemojex · channels and pubsub

Live updates ride a WebSocket channel. A player joins the channel for the game they are in, and the channel is how a result reaches them without polling. The producer of those updates is the score worker from the play path: when it records a scored guess, it publishes a scored event on the internal PubSub, addressed to that game.

PubSub is what decouples the worker from the crowd. The worker does not know or care who is connected; it publishes once, and every channel subscribed to that game forwards the event to its players. A player sees their result and the leaderboard move in the same moment the worker writes it down, and the web tier holds no per-room state to make that happen.

Whether anything is pushed at all is the mode’s call. A live room broadcasts each scored guess, so the channel is busy and immediate. A blind room publishes nothing per guess — the worker records in silence and the channel stays quiet until the settlement at the close, when the result and the payouts arrive together. The same channel and the same PubSub serve both; the policy decides what crosses them.

§4

The doors

the sibling courses
§2

References

sources · related

Sources

Related