summaryrefslogtreecommitdiffstats
path: root/web/play/src/types.ts
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-08 03:29:35 +0100
committersalmonik <salmonik@tuta.io>2026-11-08 03:29:35 +0100
commit058432130628d00764663ecf819a9adc6793768d (patch)
treed3f49f111fbfaa48647cca2600adcf9017af2d30 /web/play/src/types.ts
parentweb: serve latest.php through PHP and refuse stray PHP files (diff)
downloadzagan-bet-058432130628d00764663ecf819a9adc6793768d.tar.gz
zagan-bet-058432130628d00764663ecf819a9adc6793768d.zip
v5.0.0: protocol v5 and the browser frontend
Protocol v5 replaces newline lines with bounded [u32 len][text] frames and REQ/RES/EVT envelopes. Requests carry correlation ids and the server replays the last 256 replies per connection, so a gateway retry cannot double-debit and a late reply cannot clobber a newer request. HELLO/PONG carry server time; crash rounds announce started_at and push coalesced 10 Hz ticks. Crash now commits sha256(seed) before a round and reveals the seed when it ends, so clients recompute the crash point. Adds the webd/ gateway: one blocking thread, one ClientCore and one pinned upstream TLS connection per session, an HttpOnly session cookie, takeover, and a 60-second grace window. The browser sends Command JSON and renders View JSON; it never speaks the game protocol or stores credentials. Adds the vanilla TypeScript browser app at /play/ (login, lobby, all four games, history, notices, crash verification), the nginx /play and /ws routes, and the headless DOM smoke test. webd and the app stay out of the TUI/GUI/server build graph. The client/server version moves to 5.0.0 in lockstep; v4 peers are refused at HELLO.
Diffstat (limited to 'web/play/src/types.ts')
-rw-r--r--web/play/src/types.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/web/play/src/types.ts b/web/play/src/types.ts
new file mode 100644
index 0000000..e594a0b
--- /dev/null
+++ b/web/play/src/types.ts
@@ -0,0 +1,27 @@
1export type View = {
2 screen: "lobby" | "history" | "slots" | "roulette" | "blackjack" | "crash";
3 [key: string]: any;
4};
5
6export type Hello = {
7 type: "hello";
8 version: string;
9 grace_seconds: number;
10 /** Signed-in user restored after a refresh, if any. */
11 user?: string | null;
12 /** Estimated game-server Unix time in milliseconds. */
13 time: number;
14};
15
16export type Send = (command: unknown) => void;
17
18export type Handlers = {
19 onHello: (hello: Hello) => void;
20 onView: (view: View) => void;
21 onNotice: (text: string) => void;
22 onError: (text: string) => void;
23 onReplaced: () => void;
24 onPong: () => void;
25 onOpen: () => void;
26 onClosed: (willRetry: boolean) => void;
27};