tickflare 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +240 -0
  2. package/LICENSE +21 -0
  3. package/README.md +112 -2
  4. package/dist/binary.d.ts +91 -0
  5. package/dist/binary.js +466 -0
  6. package/dist/binary.js.map +1 -0
  7. package/dist/client/accounts.d.ts +193 -0
  8. package/dist/client/accounts.js +306 -0
  9. package/dist/client/accounts.js.map +1 -0
  10. package/dist/client/buffered.d.ts +88 -0
  11. package/dist/client/buffered.js +229 -0
  12. package/dist/client/buffered.js.map +1 -0
  13. package/dist/client/clock.d.ts +36 -0
  14. package/dist/client/clock.js +83 -0
  15. package/dist/client/clock.js.map +1 -0
  16. package/dist/client/draft.d.ts +17 -0
  17. package/dist/client/draft.js +133 -0
  18. package/dist/client/draft.js.map +1 -0
  19. package/dist/client/index.d.ts +182 -0
  20. package/dist/client/index.js +496 -0
  21. package/dist/client/index.js.map +1 -0
  22. package/dist/client/interpolate.d.ts +31 -0
  23. package/dist/client/interpolate.js +59 -0
  24. package/dist/client/interpolate.js.map +1 -0
  25. package/dist/client/lockstep.d.ts +86 -0
  26. package/dist/client/lockstep.js +339 -0
  27. package/dist/client/lockstep.js.map +1 -0
  28. package/dist/client/matchmaking.d.ts +21 -0
  29. package/dist/client/matchmaking.js +55 -0
  30. package/dist/client/matchmaking.js.map +1 -0
  31. package/dist/client/pacer.d.ts +22 -0
  32. package/dist/client/pacer.js +65 -0
  33. package/dist/client/pacer.js.map +1 -0
  34. package/dist/client/predict.d.ts +75 -0
  35. package/dist/client/predict.js +203 -0
  36. package/dist/client/predict.js.map +1 -0
  37. package/dist/client/token.d.ts +10 -0
  38. package/dist/client/token.js +15 -0
  39. package/dist/client/token.js.map +1 -0
  40. package/dist/lockstep.d.ts +154 -0
  41. package/dist/lockstep.js +140 -0
  42. package/dist/lockstep.js.map +1 -0
  43. package/dist/patch.d.ts +54 -0
  44. package/dist/patch.js +186 -0
  45. package/dist/patch.js.map +1 -0
  46. package/dist/protocol.d.ts +268 -0
  47. package/dist/protocol.js +54 -0
  48. package/dist/protocol.js.map +1 -0
  49. package/dist/server/accounts.d.ts +320 -0
  50. package/dist/server/accounts.js +1223 -0
  51. package/dist/server/accounts.js.map +1 -0
  52. package/dist/server/delta.d.ts +50 -0
  53. package/dist/server/delta.js +426 -0
  54. package/dist/server/delta.js.map +1 -0
  55. package/dist/server/frames.d.ts +15 -0
  56. package/dist/server/frames.js +23 -0
  57. package/dist/server/frames.js.map +1 -0
  58. package/dist/server/gateway.d.ts +80 -0
  59. package/dist/server/gateway.js +144 -0
  60. package/dist/server/gateway.js.map +1 -0
  61. package/dist/server/index.d.ts +21 -0
  62. package/dist/server/index.js +22 -0
  63. package/dist/server/index.js.map +1 -0
  64. package/dist/server/limiter.d.ts +12 -0
  65. package/dist/server/limiter.js +43 -0
  66. package/dist/server/limiter.js.map +1 -0
  67. package/dist/server/lockstep.d.ts +127 -0
  68. package/dist/server/lockstep.js +549 -0
  69. package/dist/server/lockstep.js.map +1 -0
  70. package/dist/server/matches.d.ts +31 -0
  71. package/dist/server/matches.js +69 -0
  72. package/dist/server/matches.js.map +1 -0
  73. package/dist/server/matchmaker.d.ts +121 -0
  74. package/dist/server/matchmaker.js +479 -0
  75. package/dist/server/matchmaker.js.map +1 -0
  76. package/dist/server/room.d.ts +402 -0
  77. package/dist/server/room.js +1896 -0
  78. package/dist/server/room.js.map +1 -0
  79. package/dist/server/signals.d.ts +18 -0
  80. package/dist/server/signals.js +37 -0
  81. package/dist/server/signals.js.map +1 -0
  82. package/dist/server/storage.d.ts +117 -0
  83. package/dist/server/storage.js +330 -0
  84. package/dist/server/storage.js.map +1 -0
  85. package/dist/server/tokens.d.ts +74 -0
  86. package/dist/server/tokens.js +117 -0
  87. package/dist/server/tokens.js.map +1 -0
  88. package/dist/server/tracked.d.ts +47 -0
  89. package/dist/server/tracked.js +270 -0
  90. package/dist/server/tracked.js.map +1 -0
  91. package/dist/world.d.ts +20 -0
  92. package/dist/world.js +21 -0
  93. package/dist/world.js.map +1 -0
  94. package/package.json +74 -4
  95. package/src/binary.ts +496 -0
  96. package/src/client/accounts.ts +423 -0
  97. package/src/client/buffered.ts +264 -0
  98. package/src/client/clock.ts +86 -0
  99. package/src/client/draft.ts +138 -0
  100. package/src/client/index.ts +631 -0
  101. package/src/client/interpolate.ts +60 -0
  102. package/src/client/lockstep.ts +398 -0
  103. package/src/client/matchmaking.ts +61 -0
  104. package/src/client/pacer.ts +67 -0
  105. package/src/client/predict.ts +239 -0
  106. package/src/client/token.ts +22 -0
  107. package/src/lockstep.ts +285 -0
  108. package/src/patch.ts +188 -0
  109. package/src/protocol.ts +300 -0
  110. package/src/server/accounts.ts +1474 -0
  111. package/src/server/delta.ts +467 -0
  112. package/src/server/frames.ts +23 -0
  113. package/src/server/gateway.ts +213 -0
  114. package/src/server/index.ts +86 -0
  115. package/src/server/limiter.ts +41 -0
  116. package/src/server/lockstep.ts +617 -0
  117. package/src/server/matches.ts +99 -0
  118. package/src/server/matchmaker.ts +537 -0
  119. package/src/server/room.ts +1999 -0
  120. package/src/server/signals.ts +46 -0
  121. package/src/server/storage.ts +392 -0
  122. package/src/server/tokens.ts +184 -0
  123. package/src/server/tracked.ts +260 -0
  124. package/src/world.ts +29 -0
  125. package/tools/rooms-report.mjs +168 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchmaker.js","sourceRoot":"","sources":["../../src/server/matchmaker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAmB,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAwC5F;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,UAAiC,SAAQ,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E,IAAI,GAAG,KAAK,CAAC;IACpE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,402 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ import { type MatchResult, type Player } from "../protocol.js";
3
+ import { type RoomNamespace } from "./gateway.js";
4
+ /** Thrown by a hook to refuse a command, a join or a leave. The reason is sent to the client. */
5
+ export declare class Rejection extends Error {
6
+ /** Sent to the client as the reason. */
7
+ readonly reason: string;
8
+ constructor(reason: string);
9
+ }
10
+ /** What `act` reports: the hook's changes were committed, or it was refused and why. */
11
+ export type ActOutcome = {
12
+ /** The hook's changes were committed and sent. */
13
+ ok: true;
14
+ } | {
15
+ /** The hook was refused: nothing it did was kept. */
16
+ ok: false;
17
+ /** What it passed to `reject()`, or `internal_error` if it threw. */
18
+ reason: string;
19
+ };
20
+ /** What one room or matchmaker asks of another over RPC. @internal */
21
+ export type RoomCall = {
22
+ op: "arrive";
23
+ roomId: string;
24
+ playerId: string;
25
+ carry: unknown;
26
+ } | {
27
+ op: "signal";
28
+ from: string | null;
29
+ data: unknown;
30
+ } | {
31
+ op: "reserve";
32
+ roomId: string;
33
+ players: string[];
34
+ teams?: string[][];
35
+ };
36
+ /** Refuse what the current hook was asked to do. Everything the hook changed is rolled back. */
37
+ export declare function reject(reason: string): never;
38
+ /** Has `room` send a patch for every tick it runs, also when catching up. @internal */
39
+ export declare function patchEachTick(room: object): void;
40
+ /**
41
+ * An authoritative game room: one Durable Object per room.
42
+ *
43
+ * Event mode (the default) has no tick loop. The room wakes when a player
44
+ * connects, sends a command, drops or leaves, or when a timer fires. It runs
45
+ * the matching hook, saves what changed and sends each connected player their
46
+ * view of the state. Between events it hibernates while the WebSockets stay
47
+ * open, and rebuilds itself from storage on the next event.
48
+ *
49
+ * State sync adds a simulation: set `tickRate` and the room calls `onTick`
50
+ * that many times a second while players are connected, sending each player
51
+ * only what changed in their view since the previous tick.
52
+ *
53
+ * Hooks are synchronous and change `this.state` in place. The state must be
54
+ * JSON-serializable. A hook that calls `reject()` or throws leaves no trace:
55
+ * state, seats and timers go back to what they were.
56
+ */
57
+ export declare abstract class Room<State, Command = unknown, Env = Cloudflare.Env> extends DurableObject<Env> {
58
+ #private;
59
+ /** How many distinct players may hold a seat at once. */
60
+ protected maxPlayers: number;
61
+ /** Longest client frame accepted, in characters. */
62
+ protected maxMessageLength: number;
63
+ /**
64
+ * How long a disconnected player keeps their seat, in milliseconds. When it
65
+ * runs out, `onLeave` is called and the seat is given up, as if the player
66
+ * had left; a later connection from them is a new join. The default,
67
+ * `Infinity`, keeps seats until the player leaves or is removed, which is
68
+ * what a game played over days wants. A real-time room should set it, or
69
+ * closed tabs fill the room for good.
70
+ */
71
+ protected seatTimeoutMs: number;
72
+ /**
73
+ * How many frames a second one player may send, and also how many they may
74
+ * send in a single burst. Frames over the limit are refused with
75
+ * `rate_limited` and never reach `parseCommand`. `Infinity` turns it off.
76
+ */
77
+ protected maxCommandsPerSecond: number;
78
+ /**
79
+ * Where `finishMatch` announces a finished match. Set it to a Queue binding:
80
+ * `protected override matchQueue = this.env.MATCHES;`
81
+ */
82
+ protected matchQueue: Queue<MatchResult> | undefined;
83
+ /**
84
+ * Where `finishMatch` stores the replay it is given, if any. Set it to an R2
85
+ * binding: `protected override matchBucket = this.env.REPLAYS;`
86
+ */
87
+ protected matchBucket: R2Bucket | undefined;
88
+ /**
89
+ * Where the other rooms are, for `movePlayer` and `signal`: the Durable
90
+ * Object namespace they live in, usually this room's own.
91
+ * `protected override rooms = this.env.ROOMS;`
92
+ */
93
+ protected rooms: RoomNamespace | undefined;
94
+ /** Simulation rate in ticks per second. 0, the default, is event mode: no tick loop. */
95
+ protected tickRate: number;
96
+ /**
97
+ * While the room is ticking, the most ticks it runs back to back to catch
98
+ * up when it wakes late. The simulation keeps to a fixed clock: tick `n`
99
+ * is due `n / tickRate` seconds after the clock started, and a room that
100
+ * wakes late, because a tick or an event took long or the machine was
101
+ * busy, runs every tick that has come due since, each with the same `dt`,
102
+ * and sends one patch for all of them.
103
+ *
104
+ * When more than this many are due, after a stall of a fraction of a
105
+ * second, the room runs this many and lets the rest go: the clock moves on,
106
+ * and the game is that much behind the wall clock for good, instead of
107
+ * fast-forwarding through a burst of ticks. 1 never catches up, which is
108
+ * how rooms ran before 0.2.
109
+ */
110
+ protected maxCatchUpTicks: number;
111
+ /**
112
+ * While the room is ticking, how often the state is written to storage, in
113
+ * milliseconds. It is also written whenever the simulation stops. A room
114
+ * that is torn down mid-simulation (a deploy, a crash) resumes from the
115
+ * last write.
116
+ */
117
+ protected saveIntervalMs: number;
118
+ /**
119
+ * While the room is ticking, how long a connection may send nothing, not
120
+ * a command and not a keepalive, before it is taken for dead and closed
121
+ * with `CloseCode.Silent`. The player is then away, as after any other
122
+ * drop: `onDisconnect` runs and their seat timeout starts.
123
+ *
124
+ * A room ticks for as long as someone is connected, and is billed for it.
125
+ * A connection whose other end is gone without the room being told would
126
+ * keep it awake for nobody, and this is what ends that. Tickflare's
127
+ * clients send a keepalive every 25 seconds, so the default of two
128
+ * minutes never closes one that is there; a client of your own has to
129
+ * send `ping` at least this often. 0 never closes a connection for
130
+ * silence. A room that is not ticking never does either: it is asleep.
131
+ */
132
+ protected silentAfterMs: number;
133
+ /**
134
+ * Whether the kernel follows what each hook writes to the state, rather
135
+ * than turning the whole state into JSON after every hook to see what
136
+ * changed and to be able to undo it. On by default: a hook then costs what
137
+ * it touches, not what the state weighs.
138
+ *
139
+ * It means that inside a hook other than `onTick`, `this.state` and
140
+ * everything reached through it are proxies of the state's objects. They
141
+ * read and write like the objects themselves, with two exceptions: a proxy
142
+ * is not `===` to an object that did not come from the state, and
143
+ * `structuredClone` refuses one. `plain(value)` gives the object underneath
144
+ * for those. Reach the state through `this.state` in every hook, rather
145
+ * than through a reference kept from an earlier one: a change made through
146
+ * such a reference is not seen until the next tick or save, and is not
147
+ * undone if the hook is refused.
148
+ *
149
+ * Set to false to have every hook work on the plain state, at the old cost.
150
+ */
151
+ protected trackChanges: boolean;
152
+ /**
153
+ * The authoritative state. Change it only inside hooks, through
154
+ * `this.state`: see `trackChanges` for what a hook is handed.
155
+ */
156
+ protected get state(): State;
157
+ /** Replaces the whole state. Like any other change, only inside hooks. */
158
+ protected set state(value: State);
159
+ constructor(ctx: DurableObjectState, env: Env);
160
+ /** The state of a brand new room. */
161
+ protected abstract initialState(): State;
162
+ /**
163
+ * Turn an untrusted client payload into a command. Check everything here:
164
+ * `raw` is whatever the client sent. Throwing refuses the command.
165
+ */
166
+ protected abstract parseCommand(raw: unknown): Command;
167
+ /** Apply a command. Call `reject()` to refuse it. */
168
+ protected abstract onCommand(player: Player, command: Command): void;
169
+ /** A player takes a seat for the first time. Call `reject()` to turn them away. */
170
+ protected onJoin(_player: Player): void;
171
+ /** A seated player's last connection closed. They keep their seat. */
172
+ protected onDisconnect(_player: Player): void;
173
+ /** A seated player connected again after being fully disconnected. */
174
+ protected onReconnect(_player: Player): void;
175
+ /**
176
+ * A player is giving up their seat: they asked to leave, or they stayed
177
+ * disconnected for longer than `seatTimeoutMs`. Tidy up after them here;
178
+ * they are removed when this returns. Call `reject()` to make them stay.
179
+ */
180
+ protected onLeave(_player: Player): void;
181
+ /**
182
+ * The last seat was given up: nobody is in the room any more, whichever way
183
+ * they went (they left, stayed away too long, were removed, or moved to
184
+ * another room). `this.players` is empty. Nothing ends a room by itself, so
185
+ * this is where to say what becomes of it: `deleteRoom()`, a timer that
186
+ * deletes it unless somebody comes back, or nothing, for a room that waits
187
+ * for its next players. Not called for a room nobody ever sat in.
188
+ *
189
+ * It runs as a hook of its own, straight after the one that emptied the
190
+ * room. If it fails it alone is undone: the players are still gone.
191
+ */
192
+ protected onEmpty(): void;
193
+ /** A timer set with `setTimer(name, ...)` ran out. */
194
+ protected onTimer(_name: string): void;
195
+ /**
196
+ * Advance the simulation by one step of `dt` seconds (always `1 / tickRate`).
197
+ * Runs `tickRate` times a second while the room is ticking, on a fixed
198
+ * clock: a room that wakes late runs the ticks it owes back to back. See
199
+ * `maxCatchUpTicks`.
200
+ */
201
+ protected onTick(_dt: number): void;
202
+ /**
203
+ * Whether the simulation should be running. Checked after every event and
204
+ * every tick, so base it on the state, e.g. `this.state.phase === "playing"`.
205
+ * While it returns false the room behaves as in event mode and can
206
+ * hibernate. The room does not tick while nobody is connected, unless
207
+ * `ticksWhileEmpty()` says so.
208
+ */
209
+ protected shouldTick(): boolean;
210
+ /**
211
+ * Whether the simulation keeps running while nobody is connected, for a
212
+ * match that has to reach its end whoever is watching. `shouldTick()` has
213
+ * to agree. Checked like `shouldTick()`, so base it on the state.
214
+ *
215
+ * Give such a room an end. It is awake, and billed, for every second it
216
+ * ticks, and nobody is there to notice one that never stops: have `onTick`
217
+ * finish or delete the room when the match is over or has run too long.
218
+ * After a deploy or a crash it carries on from its last save within
219
+ * twenty seconds.
220
+ */
221
+ protected ticksWhileEmpty(): boolean;
222
+ /**
223
+ * A plain HTTP request for this room, sent to `{prefix}/{roomId}/...` and
224
+ * already authenticated by the gateway. For reading from the room, e.g. a
225
+ * replay or a scoreboard: changes made to the state here are not saved or
226
+ * sent to anyone.
227
+ */
228
+ protected onHttp(_request: Request, _player: Player): Response | Promise<Response>;
229
+ /** What `player` is allowed to see. Defaults to the whole state. */
230
+ protected view(_player: Player): unknown;
231
+ /** Everyone with a seat, in join order. */
232
+ protected get players(): Player[];
233
+ /** Number of state changes so far. */
234
+ protected get seq(): number;
235
+ /** Number of ticks run so far. */
236
+ protected get tick(): number;
237
+ /** The id this room is reached under, once someone has connected through the gateway. */
238
+ protected get roomId(): string | null;
239
+ /**
240
+ * The players a matchmaker reserved this room for, or null if it was not
241
+ * reserved. Only they can take a seat (players handed over from another
242
+ * room aside), so a match can start once all of them have joined.
243
+ */
244
+ protected get invited(): readonly string[] | null;
245
+ /**
246
+ * The sides the matchmaker split the invited players into, each a list of
247
+ * player ids, or null if it did not: see `Matchmaker.teams`.
248
+ */
249
+ protected get teams(): readonly (readonly string[])[] | null;
250
+ /**
251
+ * Have what the current hook changes written to storage as soon as the hook
252
+ * returns, instead of at the next save interval. Only matters while the
253
+ * room is ticking; outside the simulation every change is written at once.
254
+ * Use it when the hook also writes to the room's database itself, so the
255
+ * two cannot come apart. Call from inside a hook.
256
+ */
257
+ protected saveNow(): void;
258
+ /**
259
+ * Announce that a match is over. `result` is yours to define (winner,
260
+ * scores, ...). It is put on `matchQueue` together with the room id and the
261
+ * players, for a queue consumer such as `recordMatches` to store. Pass a
262
+ * `replay` to have it written to `matchBucket` first; the message then
263
+ * carries its key. Call from inside a hook.
264
+ *
265
+ * The announcement is saved with the room and sent after the hook has
266
+ * committed. If sending fails it is tried again on the room's next event.
267
+ */
268
+ protected finishMatch(result?: Record<string, unknown>, replay?: unknown): void;
269
+ /**
270
+ * Hand a player over to another room, for worlds that are split across
271
+ * rooms. Their seat here is given up; once the other room has accepted
272
+ * them, their connection is closed with `CloseCode.Moved` and the client
273
+ * reconnects there by itself. `carry` (JSON) is delivered to the other
274
+ * room's `onArrive`: put in it whatever the player takes along. Remove
275
+ * their part of this room's state yourself. Call from inside a hook, and
276
+ * set `rooms`.
277
+ *
278
+ * A player who is not connected at that moment is sent on when they next
279
+ * connect here.
280
+ */
281
+ protected movePlayer(playerId: string, toRoomId: string, carry?: unknown): void;
282
+ /**
283
+ * Deliver a player to another room, through `roomsFor`. If it throws, the
284
+ * handover is tried again on this room's next event.
285
+ */
286
+ protected handOver(roomId: string, playerId: string, carry: unknown): Promise<void>;
287
+ /**
288
+ * A player handed over by another room takes their seat. `carry` is what
289
+ * that room passed to `movePlayer`. Defaults to treating them as a new
290
+ * player.
291
+ */
292
+ protected onArrive(player: Player, _carry: unknown): void;
293
+ /**
294
+ * Send a message to one player, outside the state: an event they should
295
+ * hear about once ("you were hit", a result with more in it than an ack),
296
+ * or a stream you keep in step yourself. The client receives it in
297
+ * `onMessage`.
298
+ *
299
+ * Messages go out when the event that sent them is over, in the order they
300
+ * were sent: after the state frame that event caused, or in a ticking room
301
+ * after the tick's patch. A message sent while handling a command can so
302
+ * arrive before the next tick shows the command's effect. A message to a
303
+ * player who is not connected is dropped, and so is everything a hook sent
304
+ * if that hook is refused. Unlike the state, nothing is sent again on
305
+ * reconnect: send what a returning player needs from `onReconnect`.
306
+ */
307
+ protected send(playerId: string, message: unknown): void;
308
+ /** `send` to every player who is connected. */
309
+ protected broadcast(message: unknown): void;
310
+ /**
311
+ * Run `task` once this event is over, outside the hook: for talking to the
312
+ * world, which hooks cannot do because they are synchronous. Writing to
313
+ * D1, calling another Durable Object, `fetch`. Dropped if the hook is
314
+ * refused. Not awaited by anything and not retried: failures are logged.
315
+ * To change the state with what comes back, use `act`; to be sure it gets
316
+ * done across restarts, keep what is owed in the state and a timer that
317
+ * tries again.
318
+ */
319
+ protected defer(task: () => unknown): void;
320
+ /**
321
+ * Run `hook` like any other hook, from code that is not one: the end of a
322
+ * deferred task, a promise that resolved, an RPC method of your own. Its
323
+ * changes are committed and sent, or all taken back if it throws or calls
324
+ * `reject()`, which is what the returned outcome reports.
325
+ */
326
+ protected act(hook: () => void): Promise<ActOutcome>;
327
+ /**
328
+ * Send a message to another room, which receives it in `onSignal`. It goes
329
+ * out once after this hook has committed. It is not saved and not retried:
330
+ * use it for things that are replaced by the next one anyway, such as a
331
+ * snapshot of what is near a border. Call from inside a hook, and set
332
+ * `rooms`.
333
+ *
334
+ * With `onlyIfWatched`, a room that reports nobody connected is left alone
335
+ * for two seconds at a time, so an empty neighbour is not kept awake.
336
+ */
337
+ protected signal(roomId: string, data: unknown, options?: {
338
+ onlyIfWatched?: boolean;
339
+ }): void;
340
+ /**
341
+ * Deliver a signal to another room, through `roomsFor`, resolving to
342
+ * whether anyone is connected there.
343
+ */
344
+ protected relay(roomId: string, data: unknown): Promise<boolean>;
345
+ /** Another room sent this one a message with `signal`. */
346
+ protected onSignal(_fromRoomId: string, _data: unknown): void;
347
+ /**
348
+ * How rooms and matchmakers reach each other over RPC: handing a player
349
+ * over, delivering a signal, reserving a room for a match. Reserved for
350
+ * Tickflare: don't call it, and don't name a method of your own `tickflare`.
351
+ * @internal
352
+ */
353
+ tickflare(call: RoomCall): Promise<unknown>;
354
+ /**
355
+ * The namespace the room called `roomId` lives in. Defaults to `rooms`.
356
+ * Override it when handovers and signals go to rooms of more than one
357
+ * class, e.g. by the id's prefix.
358
+ */
359
+ protected roomsFor(_roomId: string): RoomNamespace | undefined;
360
+ /**
361
+ * Run `onTimer(name)` once, `delayMs` from now. A timer with the same name
362
+ * is replaced. Returns the time it fires in epoch milliseconds, which you
363
+ * can put in the state to show a countdown. Call from inside a hook.
364
+ *
365
+ * Timers are saved with the room, so they survive hibernation and restarts.
366
+ */
367
+ protected setTimer(name: string, delayMs: number): number;
368
+ /**
369
+ * End this room for good. Shortly after the current event, everyone still
370
+ * connected is disconnected with `CloseCode.Removed` and the reason
371
+ * `"room_deleted"`, and everything the room stored is deleted: its state,
372
+ * seats and timers, a lockstep recording, and any tables of your own. With
373
+ * nothing stored the Durable Object itself ceases to exist.
374
+ *
375
+ * What the room still owes is delivered first: a finished match's result,
376
+ * a player on their way to another room. Until it is, the room stays.
377
+ * Work passed to `defer()` that is still running is given ten seconds to
378
+ * finish.
379
+ *
380
+ * The room id is not used up. Someone who comes to it later finds a new,
381
+ * empty room. Call from inside a hook.
382
+ */
383
+ protected deleteRoom(): void;
384
+ /** Cancel a timer. Does nothing if it is not set. Call from inside a hook. */
385
+ protected clearTimer(name: string): void;
386
+ /**
387
+ * Take a player's seat away and close their connection with
388
+ * `CloseCode.Removed` and `reason`. `onLeave` is not called: clean up their
389
+ * part of the state yourself. Call from inside a hook.
390
+ */
391
+ protected removePlayer(playerId: string, reason?: string): void;
392
+ /** Durable Object entry point for connections and HTTP requests from the gateway. Tickflare's: override `onHttp` instead. */
393
+ fetch(request: Request): Promise<Response>;
394
+ /** Durable Object entry point for incoming frames. Tickflare's: override `parseCommand` and `onCommand` instead. */
395
+ webSocketMessage(ws: WebSocket, message: string | ArrayBuffer): Promise<void>;
396
+ /** Durable Object entry point for closed connections. Tickflare's: override `onDisconnect` instead. */
397
+ webSocketClose(ws: WebSocket, code: number, reason: string): Promise<void>;
398
+ /** Durable Object entry point for broken connections. Tickflare's: override `onDisconnect` instead. */
399
+ webSocketError(ws: WebSocket): Promise<void>;
400
+ /** Durable Object entry point for the alarm that drives timers and retries. Tickflare's: override `onTimer` instead. */
401
+ alarm(): Promise<void>;
402
+ }