summaryrefslogtreecommitdiffstats
path: root/web/play/src/types.ts
blob: ae2c4c71144374c79b3a36b38082c4288ec13260 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export type View = {
  screen: "lobby" | "history" | "slots" | "roulette" | "blackjack" | "crash";
  [key: string]: any;
};

export type Hello = {
  type: "hello";
  version: string;
  grace_seconds: number;
  /** Signed-in user restored after a refresh, if any. */
  user?: string | null;
  /** Last known balance, for views that do not carry one. */
  balance?: number | null;
  /** Estimated game-server Unix time in milliseconds. */
  time: number;
};

export type Send = (command: unknown) => void;

export type Handlers = {
  onHello: (hello: Hello) => void;
  onView: (view: View) => void;
  onNotice: (text: string) => void;
  onError: (text: string) => void;
  onReplaced: () => void;
  onPong: () => void;
  onOpen: () => void;
  onClosed: (willRetry: boolean) => void;
};