From fda24c47a8262388ada92722850a362da65aaa6e Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 8 Nov 2026 03:32:24 +0100 Subject: web: accept the serialized reels array and stop game loops on navigation The Rust SlotsView serializes reels as an array of chars, so the browser joins it instead of String(array). The crash chart, reel animation and roulette observer now stop when another screen takes over, and a returning crash screen rebuilds its detached canvas. Action buttons ignore a double click before the server view arrives. Also tightens the gateway session registry with a generation token, caps WebSocket messages at 64 KiB, uses the __Host- cookie prefix on HTTPS, and ships the systemd unit. --- web/play/src/blackjack.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'web/play/src/blackjack.ts') diff --git a/web/play/src/blackjack.ts b/web/play/src/blackjack.ts index 3537f45..49d46fa 100644 --- a/web/play/src/blackjack.ts +++ b/web/play/src/blackjack.ts @@ -1,6 +1,14 @@ import type { View } from "./types"; import { cardFace, clear, money, node } from "./dom"; +let lastAction = 0; + +function actionAllowed(): boolean { + if (Date.now() - lastAction < 400) return false; + lastAction = Date.now(); + return true; +} + function cardElement(card: string): HTMLElement { if (card === "?") { const back = node("div", "card back"); @@ -124,6 +132,7 @@ export function renderBlackjack( ? node("button", "btn primary", label) : node("button", "btn", label); button.addEventListener("click", () => { + if (!actionAllowed()) return; if (action === "hit") send("Hit"); else if (action === "stand") send("Stand"); else send("Double"); @@ -133,12 +142,15 @@ export function renderBlackjack( actions.append(actionsRow); const forfeit = node("button", "btn danger wide", "Forfeit hand"); forfeit.addEventListener("click", () => { + if (!actionAllowed()) return; if (window.confirm("Forfeit this hand? The reserved bet is lost.")) send("Forfeit"); }); actions.append(forfeit); } else if (canDeal) { const deal = node("button", "btn primary wide big", "DEAL"); - deal.addEventListener("click", () => send("Deal")); + deal.addEventListener("click", () => { + if (actionAllowed()) send("Deal"); + }); actions.append(deal); } -- cgit v1.2.3