@hadoku/game-server 0.1.193 → 0.1.195

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.
@@ -5,7 +5,9 @@
5
5
  * `list`, `quarantine`) happen at boot and stay the base class's.
6
6
  *
7
7
  * `saveSync` keeps its name because the lobby calls it from every mutation and must not await; it
8
- * returns once the snapshot is queued. A save then a remove of one room land in that order.
8
+ * returns once the snapshot is queued, and the snapshot is serialised only when its write starts (a
9
+ * newer save of the room before then replaces it unserialised). A save then a remove of one room land
10
+ * in that order.
9
11
  */
10
12
  import { FileRoomStore, type RoomSnapshot } from '@wolffm/rooms-server/store';
11
13
  import { type SnapshotWriter } from '../persist/snapshot-writer.js';
@@ -5,7 +5,9 @@
5
5
  * `list`, `quarantine`) happen at boot and stay the base class's.
6
6
  *
7
7
  * `saveSync` keeps its name because the lobby calls it from every mutation and must not await; it
8
- * returns once the snapshot is queued. A save then a remove of one room land in that order.
8
+ * returns once the snapshot is queued, and the snapshot is serialised only when its write starts (a
9
+ * newer save of the room before then replaces it unserialised). A save then a remove of one room land
10
+ * in that order.
9
11
  */
10
12
  import { join } from 'node:path';
11
13
  import { FileRoomStore } from '@wolffm/rooms-server/store';
@@ -22,7 +24,8 @@ export class OffLoopRoomStore extends FileRoomStore {
22
24
  return join(this.dir, `${Buffer.from(roomId, 'utf8').toString('base64url')}${SUFFIX}`);
23
25
  }
24
26
  saveSync(snapshot) {
25
- this.#writer.write(this.fileOf(snapshot.roomId), JSON.stringify(snapshot));
27
+ // Serialised when its write starts: a burst of mutations to one room costs one stringify, not one each.
28
+ this.#writer.write(this.fileOf(snapshot.roomId), () => JSON.stringify(snapshot));
26
29
  }
27
30
  save(snapshot) {
28
31
  this.saveSync(snapshot);
@@ -30,6 +30,12 @@
30
30
  * same name, picture and character, and a rename reaches the other players' room list with
31
31
  * nobody rejoining.
32
32
  *
33
+ * `looks` is the same lookup for chat history: the room layer's one naming rule (`presentChat`,
34
+ * `@wolffm/rooms-server/chat`) names a line's author and its reactors from their connection while
35
+ * they are here, else from their account through `people`, so someone who has left reads as
36
+ * their current name rather than "Someone". It reads the cache (no `fresh`): one batched call
37
+ * per history page, and a stale name there is a name, not a wrong one.
38
+ *
33
39
  * ## Who may join
34
40
  *
35
41
  * `admit` is the gate: the tier floor (the same one every socket applies), a key this app minted
@@ -30,6 +30,12 @@
30
30
  * same name, picture and character, and a rename reaches the other players' room list with
31
31
  * nobody rejoining.
32
32
  *
33
+ * `looks` is the same lookup for chat history: the room layer's one naming rule (`presentChat`,
34
+ * `@wolffm/rooms-server/chat`) names a line's author and its reactors from their connection while
35
+ * they are here, else from their account through `people`, so someone who has left reads as
36
+ * their current name rather than "Someone". It reads the cache (no `fresh`): one batched call
37
+ * per history page, and a stale name there is a name, not a wrong one.
38
+ *
33
39
  * ## Who may join
34
40
  *
35
41
  * `admit` is the gate: the tier floor (the same one every socket applies), a key this app minted
@@ -222,6 +228,10 @@ export async function attachServedRoom(io, deps) {
222
228
  // made while their socket was down: a restart's resumed match fills it, and the chrome's
223
229
  // `identity_update` for a pick made before the socket rejoined is dropped ("join the room
224
230
  // first"), so this read is the only one that sees the pick.
231
+ async looks(accountIds) {
232
+ const found = await people.resolve(accountIds);
233
+ return new Map([...found].map(([id, person]) => [id, { name: person.name, sprite: person.sprite }]));
234
+ },
225
235
  async account(accountId) {
226
236
  const person = (await people.resolve([accountId], { fresh: true })).get(accountId);
227
237
  if (person === undefined)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-server",
3
- "version": "0.1.193",
4
- "gitHead": "deaeb22ad2c9c3c0a49cebe4d8d06f812c743f60",
3
+ "version": "0.1.195",
4
+ "gitHead": "43473a09e2f2d07dd684b2aa45ac5c250e145d50",
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.193",
21
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.193",
22
- "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.226",
20
+ "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.195",
21
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.195",
22
+ "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.228",
23
23
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
24
24
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.150",
25
25
  "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.150",