@hadoku/game-server 0.1.166 → 0.1.168
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.
- package/dist/room/serve.d.ts +12 -0
- package/dist/room/serve.js +13 -2
- package/dist/timers.d.ts +4 -0
- package/dist/timers.js +26 -0
- package/package.json +5 -5
package/dist/room/serve.d.ts
CHANGED
|
@@ -58,6 +58,18 @@ import { type RoomChatMessage } from '@wolffm/rooms-server/chat';
|
|
|
58
58
|
import { type ServedRoom } from '@wolffm/rooms-server/room';
|
|
59
59
|
import type { Look } from '@wolffm/platform-wire/look';
|
|
60
60
|
import { type People } from '../people.js';
|
|
61
|
+
/** A room's chat file is read back for this long after boot; older, it is deleted on sight. */
|
|
62
|
+
export declare const CHAT_RETENTION_MS: number;
|
|
63
|
+
/**
|
|
64
|
+
* The delay the store schedules a CLOSED room's chat wipe at (`roomLifeMs` below). The retention
|
|
65
|
+
* above is what `loadFromDisk` prunes by; this is a timer, and `@hadoku/rooms-server`'s
|
|
66
|
+
* `clearRoomChat` hands it straight to `setTimeout`, which keeps a delay in a 32-bit signed int and
|
|
67
|
+
* clamps anything longer TO 1 MS — so the full 90 days wiped a closed room's chat on the spot and
|
|
68
|
+
* warned `TimeoutOverflowWarning: 7776000000 …` once per room (four or five per boot in prod, and
|
|
69
|
+
* on PPE). Capped (`../timers.ts`), the wipe is late rather than immediate, and boot-time pruning
|
|
70
|
+
* still enforces the 90 days it was asked for.
|
|
71
|
+
*/
|
|
72
|
+
export declare const CHAT_WIPE_DELAY_MS: number;
|
|
61
73
|
/** The minimal room-view shape this file touches, whatever the game. The real `PlatformRoomView` (and Magic's `RoomView`) satisfy it. */
|
|
62
74
|
export interface ServeRoomView {
|
|
63
75
|
id: string;
|
package/dist/room/serve.js
CHANGED
|
@@ -56,6 +56,7 @@ import { participantHandle } from '@wolffm/rooms-protocol';
|
|
|
56
56
|
import { createChatHistoryStore } from '@wolffm/rooms-server/chat';
|
|
57
57
|
import { serveRoom } from '@wolffm/rooms-server/room';
|
|
58
58
|
import { rankOf } from '../edge-auth.js';
|
|
59
|
+
import { timerDelay } from '../timers.js';
|
|
59
60
|
import { applyPerson } from '../people.js';
|
|
60
61
|
import { handshakeEdgeTier, handshakeTier } from './socket-auth.js';
|
|
61
62
|
import { roomAdmits } from './tier-floor.js';
|
|
@@ -65,7 +66,17 @@ const MAX_MESSAGES_PER_ROOM = 500;
|
|
|
65
66
|
const PAGE_LIMIT = 50;
|
|
66
67
|
const PAGE_LIMIT_MAX = 100;
|
|
67
68
|
/** A room's chat file is read back for this long after boot; older, it is deleted on sight. */
|
|
68
|
-
const CHAT_RETENTION_MS = 90 * 24 * 60 * 60 * 1000;
|
|
69
|
+
export const CHAT_RETENTION_MS = 90 * 24 * 60 * 60 * 1000;
|
|
70
|
+
/**
|
|
71
|
+
* The delay the store schedules a CLOSED room's chat wipe at (`roomLifeMs` below). The retention
|
|
72
|
+
* above is what `loadFromDisk` prunes by; this is a timer, and `@hadoku/rooms-server`'s
|
|
73
|
+
* `clearRoomChat` hands it straight to `setTimeout`, which keeps a delay in a 32-bit signed int and
|
|
74
|
+
* clamps anything longer TO 1 MS — so the full 90 days wiped a closed room's chat on the spot and
|
|
75
|
+
* warned `TimeoutOverflowWarning: 7776000000 …` once per room (four or five per boot in prod, and
|
|
76
|
+
* on PPE). Capped (`../timers.ts`), the wipe is late rather than immediate, and boot-time pruning
|
|
77
|
+
* still enforces the 90 days it was asked for.
|
|
78
|
+
*/
|
|
79
|
+
export const CHAT_WIPE_DELAY_MS = timerDelay(CHAT_RETENTION_MS);
|
|
69
80
|
/**
|
|
70
81
|
* `<appId>-<id>` → the place it names, or null when it is not one of ours or names nothing live.
|
|
71
82
|
* A table's key is `<roomId>-<tableId>`, or `<roomId>-<matchId>` when the screen's copy of the
|
|
@@ -138,7 +149,7 @@ export async function attachServedRoom(io, deps) {
|
|
|
138
149
|
maxMessages: MAX_MESSAGES_PER_ROOM,
|
|
139
150
|
pageLimit: PAGE_LIMIT,
|
|
140
151
|
pageLimitMax: PAGE_LIMIT_MAX,
|
|
141
|
-
roomLifeMs: () =>
|
|
152
|
+
roomLifeMs: () => CHAT_WIPE_DELAY_MS,
|
|
142
153
|
safeRoomId: deps.roomIdRe,
|
|
143
154
|
onEvent: deps.onEvent === undefined ? undefined : (level, event, roomId, fields) => deps.onEvent?.(level, event, { roomId, ...fields }),
|
|
144
155
|
});
|
package/dist/timers.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The longest delay `setTimeout` keeps as given: 2^31 - 1 ms, a shade under 24.9 days. */
|
|
2
|
+
export declare const MAX_TIMER_DELAY_MS = 2147483647;
|
|
3
|
+
/** `ms` as a delay a timer keeps: never negative, never absent, never past what a 32-bit int holds. */
|
|
4
|
+
export declare function timerDelay(ms: number): number;
|
package/dist/timers.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A delay any `setTimeout` on this server can actually hold.
|
|
3
|
+
*
|
|
4
|
+
* Node keeps a timer's delay in a 32-bit signed integer. A longer one is not
|
|
5
|
+
* rounded down or refused: it is **clamped to 1 ms**, with a
|
|
6
|
+
* `TimeoutOverflowWarning` on stderr, so a timer meant for weeks away fires on
|
|
7
|
+
* the next tick — the opposite of what the caller asked for. Prod and PPE
|
|
8
|
+
* warned `TimeoutOverflowWarning: 7776000000 does not fit into a 32-bit signed
|
|
9
|
+
* integer. Timeout duration was set to 1.` four or five times per boot, which
|
|
10
|
+
* was a closed room's 90-day chat wipe happening immediately
|
|
11
|
+
* (`room/serve.ts`'s `CHAT_RETENTION_MS` reaching `@hadoku/rooms-server`'s own
|
|
12
|
+
* `setTimeout` through `roomLifeMs`).
|
|
13
|
+
*
|
|
14
|
+
* So every delay computed from a retention, a lifetime or a TTL — anything
|
|
15
|
+
* that can outgrow 24.8 days — goes through `timerDelay` on its way to a
|
|
16
|
+
* timer. Capping it makes the timer LATE at worst; not capping it makes it
|
|
17
|
+
* immediate, which is a different behaviour entirely.
|
|
18
|
+
*/
|
|
19
|
+
/** The longest delay `setTimeout` keeps as given: 2^31 - 1 ms, a shade under 24.9 days. */
|
|
20
|
+
export const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
21
|
+
/** `ms` as a delay a timer keeps: never negative, never absent, never past what a 32-bit int holds. */
|
|
22
|
+
export function timerDelay(ms) {
|
|
23
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
24
|
+
return 0;
|
|
25
|
+
return Math.min(Math.floor(ms), MAX_TIMER_DELAY_MS);
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/game-server",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.168",
|
|
4
|
+
"gitHead": "5efa439df716915a7e81a585900f9869bf7a9561",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The server parts any hosted game shares, above the kernel: the app config and edge auth, the room core (identity, seats, sessions, membership, the room list, the generic room routes), match hosting (the host contract, local and remote JVMs, placement, the start queue, recordings, the in-process and relay runtimes), streams, erase, telemetry and usage. Knows no game; Magic plugs in from apps/server. MIT; imports only node built-ins, express, socket.io, @wolffm/* and the platform packages.",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"play/remote/"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.
|
|
21
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
22
|
-
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.
|
|
20
|
+
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.168",
|
|
21
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.168",
|
|
22
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.201",
|
|
23
23
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.2",
|
|
24
24
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.144",
|
|
25
25
|
"@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.144",
|