@ksaa-nlp/gamehub-sdk 4.0.0 → 4.3.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.
- package/README.md +75 -1
- package/SPEC.md +131 -6
- package/dist/gamehub-sdk.js +354 -11
- package/dist/gamehub-sdk.js.map +4 -4
- package/dist/src/bridge.d.ts +0 -14
- package/dist/src/bridge.d.ts.map +1 -1
- package/dist/src/bridge.js +57 -1
- package/dist/src/bridge.js.map +1 -1
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/init.d.ts +0 -14
- package/dist/src/init.d.ts.map +1 -1
- package/dist/src/init.js +7 -1
- package/dist/src/init.js.map +1 -1
- package/dist/src/main.d.ts +17 -20
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +20 -1
- package/dist/src/main.js.map +1 -1
- package/dist/src/multiplayer-session.d.ts +8 -0
- package/dist/src/multiplayer-session.d.ts.map +1 -0
- package/dist/src/multiplayer-session.js +216 -0
- package/dist/src/multiplayer-session.js.map +1 -0
- package/dist/src/multiplayer.d.ts +4 -0
- package/dist/src/multiplayer.d.ts.map +1 -0
- package/dist/src/multiplayer.js +91 -0
- package/dist/src/multiplayer.js.map +1 -0
- package/dist/src/server-entry.d.ts +15 -5
- package/dist/src/server-entry.d.ts.map +1 -1
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/session.js +6 -0
- package/dist/src/session.js.map +1 -1
- package/dist/src/settings.d.ts +7 -0
- package/dist/src/settings.d.ts.map +1 -0
- package/dist/src/settings.js +49 -0
- package/dist/src/settings.js.map +1 -0
- package/dist/src/state.d.ts +7 -1
- package/dist/src/state.d.ts.map +1 -1
- package/dist/src/state.js +5 -9
- package/dist/src/state.js.map +1 -1
- package/dist/types/bootstrap.d.ts +44 -0
- package/dist/types/bootstrap.d.ts.map +1 -1
- package/dist/types/multiplayer-session.d.ts +76 -0
- package/dist/types/multiplayer-session.d.ts.map +1 -0
- package/dist/types/multiplayer-session.js +2 -0
- package/dist/types/multiplayer-session.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -237,7 +237,7 @@ sdk.reportWord({
|
|
|
237
237
|
});
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
All of these are fire-and-forget — they just signal the host (over whichever transport is active). `reportQuestion` / `reportWord` ask the host to open its report dialog (the host collects the reason + optional message
|
|
240
|
+
All of these are fire-and-forget — they just signal the host (over whichever transport is active). `reportQuestion` / `reportWord` ask the host to open its report dialog (the host collects the reason + optional message for logged-in users and submits it; guests see a login prompt). Pass `questions` / `words` instead of a single id to have the host render a dropdown so the player chooses which item to report.
|
|
241
241
|
|
|
242
242
|
## Pause/resume from the host
|
|
243
243
|
|
|
@@ -382,3 +382,77 @@ See [SPEC.md §21bis](./SPEC.md#21bis-ugc-server-bundle-subpath) for the full co
|
|
|
382
382
|
## License
|
|
383
383
|
|
|
384
384
|
ISC.
|
|
385
|
+
|
|
386
|
+
## Account-wide game settings
|
|
387
|
+
|
|
388
|
+
Music is **off by default**, including guests and older hosts. GameHub delivers
|
|
389
|
+
saved account preferences in bootstrap and pushes updates in the current host.
|
|
390
|
+
The SDK provides settings; your game implements the audio behavior.
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
await sdk.ready();
|
|
394
|
+
const initialSettings = sdk.getSettings(); // { musicEnabled: false } by default
|
|
395
|
+
const unsubscribe = sdk.onSettingsChange(({ musicEnabled }) => {
|
|
396
|
+
// Apply to current AND future background music; keep your local mute too.
|
|
397
|
+
audio.setMusicAllowed(musicEnabled);
|
|
398
|
+
});
|
|
399
|
+
// On game teardown:
|
|
400
|
+
unsubscribe();
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Callbacks immediately receive a snapshot and subsequently receive changes.
|
|
404
|
+
You can subscribe before `ready()` to keep music off during startup. Settings
|
|
405
|
+
are also available as `sdk.getBootstrap().settings`. Enabling music permits
|
|
406
|
+
playback subject to browser autoplay and the game's local mute; it must not
|
|
407
|
+
unmute sound effects or speech. Existing games need an integration update.
|
|
408
|
+
|
|
409
|
+
For a runnable reference game, serve the repository root with an HTTP static
|
|
410
|
+
server and open `packages/gamehub-sdk/demos/game-settings/index.html`.
|
|
411
|
+
The example host toggles music during gameplay; the game uses a separate gain
|
|
412
|
+
node for background music so sound effects remain independent. This is a
|
|
413
|
+
local integration demo; the GameHub profile is the production preference editor.
|
|
414
|
+
|
|
415
|
+
## Multiplayer v2 (SDK 4.2)
|
|
416
|
+
|
|
417
|
+
Use `await sdk.ready()` before reading `sdk.getBootstrap().multiplayerLaunch`.
|
|
418
|
+
`requestMultiplayerLaunch()` requests only that already-bound launch from a
|
|
419
|
+
capable trusted host and accepts no room/game override. It returns reserved,
|
|
420
|
+
recoverable or terminal. The SDK owns no realtime connection or persistent token.
|
|
421
|
+
Use [@ksaa-nlp/gamehub-multiplayer](../gamehub-multiplayer/README.md) for socket,
|
|
422
|
+
state, clock and recovery lifecycle. The [Take Twenty-One starter](../../examples/take-twenty-one/README.md)
|
|
423
|
+
contains a complete authoring/build/upload example. V1 bootstrap is unchanged;
|
|
424
|
+
unsupported/native hosts do not advertise v2. Server-authoritative v2 rounds use
|
|
425
|
+
ctx.endMatch version 2 instead of browser submitScore/submitMatchResult.
|
|
426
|
+
|
|
427
|
+
## Create and join inside your game (SDK 4.3)
|
|
428
|
+
|
|
429
|
+
Declare `lobbyUi: "game"` in `gamehub.multiplayer.json`, then disable the game's
|
|
430
|
+
platform-lobby setting. Wait for bootstrap and implement the menu using typed
|
|
431
|
+
host controls. Hosts retain authentication and session ownership.
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
await sdk.ready();
|
|
435
|
+
const off = sdk.onMultiplayerSessionChange(({ session, busy, error }) => {
|
|
436
|
+
// Render roster, ready/start controls and errors. Disable operations while busy.
|
|
437
|
+
});
|
|
438
|
+
await sdk.requestMultiplayerSession({ operation: 'create', type: 'player' });
|
|
439
|
+
// In another browser:
|
|
440
|
+
await sdk.requestMultiplayerSession({
|
|
441
|
+
operation: 'join',
|
|
442
|
+
roomCode: '123456',
|
|
443
|
+
displayName: 'Player',
|
|
444
|
+
type: 'player',
|
|
445
|
+
});
|
|
446
|
+
await sdk.requestMultiplayerSession({ operation: 'ready', ready: true });
|
|
447
|
+
// Current host only; all minimum human/player and readiness rules still apply.
|
|
448
|
+
await sdk.requestMultiplayerSession({ operation: 'start' });
|
|
449
|
+
off();
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
Use `multiplayerEntry` to prefill invitation code and spectator intent. Public
|
|
453
|
+
session snapshots contain invitation URLs, limits, roster and current round
|
|
454
|
+
phase. Rematch availability follows terminal round phases, not only eventual
|
|
455
|
+
session retirement. Start transitions to a newly mounted pinned game document;
|
|
456
|
+
read `multiplayerLaunch` there and connect the multiplayer adapter. Lobby menus
|
|
457
|
+
cannot start/submit ordinary client scores. See the starter for ready/start,
|
|
458
|
+
bots, leave and rematch controls.
|
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# GameHub SDK — Specification
|
|
2
2
|
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.0
|
|
4
4
|
Status: Authoritative. Supersedes README/MIGRATION/CHANGELOG where they conflict.
|
|
5
5
|
|
|
6
6
|
This document is the single source of truth for the GameHub SDK. Code, tests, and consumer docs follow this spec; if a behaviour is observed in code but not described here, treat it as undocumented and revisit before relying on it.
|
|
@@ -9,12 +9,13 @@ This document is the single source of truth for the GameHub SDK. Code, tests, an
|
|
|
9
9
|
|
|
10
10
|
## 1. Purpose
|
|
11
11
|
|
|
12
|
-
The GameHub SDK is the client library that GameHub-hosted games use to talk to the GameHub platform. It is a thin, transport-agnostic adapter providing
|
|
12
|
+
The GameHub SDK is the client library that GameHub-hosted games use to talk to the GameHub platform. It is a thin, transport-agnostic adapter providing five capabilities:
|
|
13
13
|
|
|
14
14
|
1. **Bootstrap pipeline.** A cross-origin `postMessage` handshake with the host page to discover the active game, the user's auth context, and (when applicable) a multiplayer reconnection token.
|
|
15
15
|
2. **Sessions and scoring.** HTTP wrappers that open a session token and submit scores, with auto-init of the session when a submit is the first call.
|
|
16
16
|
3. **Questions.** HTTP wrapper for the questions endpoint, used by quiz-style games.
|
|
17
17
|
4. **League-match HTTP.** Wrappers for the league-match context fetch and the match-result submit endpoint.
|
|
18
|
+
5. **Game settings.** Read account-wide preferences and subscribe to trusted host updates; games implement their own audio behavior.
|
|
18
19
|
|
|
19
20
|
The SDK is not coupled to any realtime transport. When the host attaches a multiplayer room, the SDK exposes the connection parameters verbatim and the game opens its own socket.
|
|
20
21
|
|
|
@@ -61,6 +62,7 @@ The package is laid out flat under `src/` and `types/`. No subdirectories.
|
|
|
61
62
|
| `src/session.ts` | `startSession`, `submitScore`, `submitMatchScore`, `submitMatchResult`, `getQuestions`, `getWords`. |
|
|
62
63
|
| `src/match-context.ts` | `fetchMatchContext` (HTTP `/leagues/<id>/matches/<id>`). |
|
|
63
64
|
| `src/api-client.ts` | `apiRequest`: thin `fetch` wrapper that prefixes the API base and attaches the Bearer token. |
|
|
65
|
+
| `src/settings.ts` | Settings snapshots, validated merge and isolated subscriptions. |
|
|
64
66
|
| `src/state.ts` | `SdkState` interface + the singleton `state` object. All mutable state lives here. |
|
|
65
67
|
| `src/constants.ts` | `SDK_VERSION`, `MESSAGE_PREFIX`, `PARENT_REQUEST_TIMEOUT_MS`, `QUESTIONS_LIMIT_CAP`, `WORDS_LIMIT_CAP`. |
|
|
66
68
|
| `src/utils.ts` | `isBrowser`, `warn`, `error`, `unwrapResult`, `readQueryParam`. |
|
|
@@ -234,13 +236,42 @@ On the **native** transport there is no web origin: inbound `HostMessage.origin`
|
|
|
234
236
|
|
|
235
237
|
This lets the host clear fields explicitly (via `null`) without overwriting unset fields.
|
|
236
238
|
|
|
239
|
+
### 6.4a Account-wide game settings
|
|
240
|
+
|
|
241
|
+
`GameSettings` is `{ readonly musicEnabled: boolean }`. The effective default is
|
|
242
|
+
`false` for guests, standalone execution, old hosts, missing/invalid initial
|
|
243
|
+
preferences and legacy accounts. No setting enables sound implicitly.
|
|
244
|
+
|
|
245
|
+
`BootstrapConfig.settings` is optional. Omission preserves current settings;
|
|
246
|
+
explicit `null` resets music to false. A non-array object with a boolean
|
|
247
|
+
`musicEnabled` applies that value and strips unknown fields. Every other shape
|
|
248
|
+
is ignored. `BootstrapData.settings` always contains a detached snapshot.
|
|
249
|
+
Settings use the existing correlated `BOOTSTRAP` and subsequent unsolicited
|
|
250
|
+
`BOOTSTRAP` protocol, with exactly the existing parent/origin/native trust rules.
|
|
251
|
+
No new message type, storage or realtime transport is introduced.
|
|
252
|
+
|
|
253
|
+
`getSettings()` synchronously returns a detached snapshot. It does not wait for
|
|
254
|
+
initialization. `onSettingsChange(listener)` installs the ambient host listener,
|
|
255
|
+
registers a callback, immediately delivers a fresh snapshot, and returns an
|
|
256
|
+
idempotent unsubscribe function. Subscribing before `ready()` is supported.
|
|
257
|
+
Subsequent callbacks run synchronously only when the effective value changes.
|
|
258
|
+
Each registration is independent, including repeated registrations of the same
|
|
259
|
+
function. Listener exceptions cannot escape or prevent delivery to other
|
|
260
|
+
listeners; consumer mutation never changes SDK state. Callbacks are local and
|
|
261
|
+
emit no telemetry. `ready()` can still be awaited before reading settings.
|
|
262
|
+
|
|
263
|
+
Games must apply `false` to all current and future background music. `true`
|
|
264
|
+
permits music subject to their own mute and browser autoplay rules; it does not
|
|
265
|
+
force playback. Sound effects, speech and instructional audio are unaffected.
|
|
266
|
+
The SDK does not control HTML media, Web Audio, game engines or DOM elements.
|
|
267
|
+
|
|
237
268
|
### 6.5 Bootstrap lifecycle
|
|
238
269
|
|
|
239
270
|
1. **Idle.** `state.bootstrapReceived = false`.
|
|
240
271
|
2. **Request.** First call to `requestBootstrapFromParent()` posts `BOOTSTRAP_REQUEST` and starts the timeout.
|
|
241
272
|
3. **Response.** Host replies with `BOOTSTRAP` carrying the matching `messageId`. `state.bootstrapReceived = true`; the direct parent's non-opaque origin is pinned.
|
|
242
273
|
4. **Cache.** Subsequent calls return `snapshotBootstrap()` synchronously (wrapped in a resolved promise).
|
|
243
|
-
5. **Update.** Any later unsolicited `BOOTSTRAP` from the host triggers `mergeBootstrapConfig` without affecting `bootstrapReceived`. Existing callers do not get re-notified.
|
|
274
|
+
5. **Update.** Any later unsolicited `BOOTSTRAP` from the host triggers `mergeBootstrapConfig` without affecting `bootstrapReceived`. Existing bootstrap callers do not get re-notified; settings subscriptions are notified when the effective settings change.
|
|
244
275
|
|
|
245
276
|
A standalone (non-iframe) game has no parent; `requestBootstrapFromParent()` resolves `null` immediately, and `state.bootstrapReceived` stays `false`. `autoInit()` still runs the slug-only path.
|
|
246
277
|
|
|
@@ -492,7 +523,7 @@ Full field tables in `types/word.ts` and `specs/words-bank-feature.md` §3.
|
|
|
492
523
|
Mirrors `reportQuestion`: fires the `WORD_REPORT` postMessage with
|
|
493
524
|
`{ wordId?, lemma?, message?, words? }` for the host to render its
|
|
494
525
|
`ReportWordDialog`. No-ops outside the host iframe (the SDK never calls the
|
|
495
|
-
report endpoint itself). See §6.1.
|
|
526
|
+
report endpoint itself). The host requires login, using the same guest/expired-session login prompt as question reports. This is host/API behavior only; the SDK message contract and version are unchanged. See §6.1.
|
|
496
527
|
|
|
497
528
|
## 12. Host command channel
|
|
498
529
|
|
|
@@ -557,6 +588,10 @@ interface SdkState {
|
|
|
557
588
|
}
|
|
558
589
|
```
|
|
559
590
|
|
|
591
|
+
The singleton also owns `gameSettings` (initial `{ musicEnabled: false }`) and
|
|
592
|
+
`settingsListeners` (initial empty Set). Settings mutate only via the validated
|
|
593
|
+
bootstrap merge; subscriptions hold callbacks only in memory.
|
|
594
|
+
|
|
560
595
|
### 13.1 Invariants
|
|
561
596
|
|
|
562
597
|
- `apiBase` is set exactly once, by `detectEnvironment()`, before any HTTP request. It is never mutated afterwards.
|
|
@@ -621,13 +656,20 @@ interface SdkState {
|
|
|
621
656
|
| `logEvent(eventName, eventData?)` | `void` | `LOG_EVENT { event: eventName, data: eventData }` |
|
|
622
657
|
| `reportQuestion(data)` | `void` | `QUESTION_REPORT { questionId?, prompt?, message?, questions? }` |
|
|
623
658
|
|
|
624
|
-
`reportQuestion(data: ReportQuestionData)` asks the host to open its "report this question" dialog. The host owns the dialog (the SDK renders no DOM — see §19.3) and submits the report, collecting the reason
|
|
659
|
+
`reportQuestion(data: ReportQuestionData)` asks the host to open its "report this question" dialog. The host owns the dialog (the SDK renders no DOM — see §19.3) and submits the report, collecting the reason and an optional message for logged-in users. Guests receive a login prompt from the host; report endpoints require a verified account token. A host submission returning `401` also shows the login prompt. Like the other host signals it no-ops outside an iframe.
|
|
625
660
|
|
|
626
661
|
Two modes:
|
|
627
662
|
|
|
628
663
|
- **Single question** — pass `questionId` (and optionally `prompt`). The dialog reports that one question.
|
|
629
664
|
- **Pick from a list** — pass `questions: ReportableQuestion[]` (each `{ questionId, prompt? }`). The host renders a dropdown so the player chooses which question to report; `questionId`, when also supplied, pre-selects an entry. The `questions` array is forwarded verbatim (each entry normalised to `{ questionId, prompt }`) on the `QUESTION_REPORT` envelope.
|
|
630
665
|
|
|
666
|
+
### 14.7a Game settings
|
|
667
|
+
|
|
668
|
+
| Method | Returns | Notes |
|
|
669
|
+
| ---------------------------- | -------------- | --------------------------------------------------------------- |
|
|
670
|
+
| `getSettings()` | `GameSettings` | Detached effective snapshot; default music off. |
|
|
671
|
+
| `onSettingsChange(listener)` | `() => void` | Immediate snapshot, then changes; unsubscribe on game teardown. |
|
|
672
|
+
|
|
631
673
|
### 14.7 Read-only context
|
|
632
674
|
|
|
633
675
|
| Method | Returns | Notes |
|
|
@@ -661,7 +703,12 @@ interface BootstrapMultiplayer {
|
|
|
661
703
|
connectionScope?: string;
|
|
662
704
|
}
|
|
663
705
|
|
|
706
|
+
interface GameSettings {
|
|
707
|
+
readonly musicEnabled: boolean;
|
|
708
|
+
}
|
|
709
|
+
|
|
664
710
|
interface BootstrapConfig {
|
|
711
|
+
settings?: GameSettings | null;
|
|
665
712
|
gameSlug?: string | null;
|
|
666
713
|
authToken?: string | null;
|
|
667
714
|
leagueId?: string | null;
|
|
@@ -678,6 +725,7 @@ interface BootstrapConfig {
|
|
|
678
725
|
}
|
|
679
726
|
|
|
680
727
|
interface BootstrapData {
|
|
728
|
+
settings: GameSettings;
|
|
681
729
|
gameSlug: string | null;
|
|
682
730
|
authToken: string | null;
|
|
683
731
|
leagueId: string | null;
|
|
@@ -924,7 +972,7 @@ These rules exist because of a real prior regression where transport-related cle
|
|
|
924
972
|
|
|
925
973
|
### 20.3 Bundle budget
|
|
926
974
|
|
|
927
|
-
The IIFE bundle (`dist/gamehub-sdk.js`) must remain under **
|
|
975
|
+
The IIFE bundle (`dist/gamehub-sdk.js`) must remain under **52 KiB raw** and **12 KiB gzip**. SDK 4.3 deliberately raises the previous 44/10 KiB limits to include bounded lobby-state validation, typed host controls and independent subscriptions. Runtime dependencies remain empty; the distribution test checks the built and served bytes and both budgets.
|
|
928
976
|
|
|
929
977
|
### 20.4 No runtime dependencies
|
|
930
978
|
|
|
@@ -1016,6 +1064,13 @@ or capability. Their existing Usage Intelligence feature IDs and accepted-only
|
|
|
1016
1064
|
server-operation observation remain authoritative; no scanner/report inventory
|
|
1017
1065
|
version change is required for this release.
|
|
1018
1066
|
|
|
1067
|
+
Version 4.1.0 adds `getSettings` and `onSettingsChange`, both static-only in the
|
|
1068
|
+
Usage Intelligence Report: a host delivering preferences proves neither their
|
|
1069
|
+
consumption nor audio compliance. Scanner version 2, admin Arabic labels,
|
|
1070
|
+
filters/CSV and fixtures are synchronized. Runtime aggregation excludes these
|
|
1071
|
+
local APIs. The example in `demos/game-settings/` is a reference game and
|
|
1072
|
+
host for manual testing of global/local mute and live preference updates.
|
|
1073
|
+
|
|
1019
1074
|
## 21bis. UGC server bundle subpath
|
|
1020
1075
|
|
|
1021
1076
|
The `./server` and `./server/dev` subpaths are separate from the browser SDK. Importing them has **no overlap** with the iframe runtime — they target the colyseus UGC sandbox, not the browser host.
|
|
@@ -1083,3 +1138,73 @@ expect(room.outbox).toContainEqual({
|
|
|
1083
1138
|
- **Host.** The GameHub-served page that frames the game in an iframe. Owns auth, matchmaking, and the bootstrap pipeline.
|
|
1084
1139
|
- **Game.** The iframe-hosted application that consumes this SDK.
|
|
1085
1140
|
- **Standalone.** A game loaded outside an iframe. `isInIframe()` returns false; the bootstrap pipeline is skipped.
|
|
1141
|
+
|
|
1142
|
+
## Launch v2 (4.2.0)
|
|
1143
|
+
|
|
1144
|
+
The authoritative cross-package contract is [multiplayer v2](../../specs/multiplayer.md).
|
|
1145
|
+
Optional bootstrap `capabilities` and `multiplayerLaunch` are separate from the
|
|
1146
|
+
unchanged required v1 `multiplayer.reservation` shape. `requestMultiplayerLaunch()`
|
|
1147
|
+
is a no-argument, single-flight request to the trusted host for its already-bound
|
|
1148
|
+
round. It validates bounded replies and fences a changed launch context. It owns
|
|
1149
|
+
no socket or persistent storage. Old/native hosts do not advertise v2 and return
|
|
1150
|
+
`PROTOCOL_UNSUPPORTED`; no fallback room is chosen.
|
|
1151
|
+
|
|
1152
|
+
`ready()` completes bootstrap before a module consumer reads its launch. V2
|
|
1153
|
+
bootstrap suppresses unrelated client-scored session creation; the host permits
|
|
1154
|
+
only the bound launch request and the backend rejects browser ownership of
|
|
1155
|
+
server-multiplayer PlayerSessions. Solo and legacy HTTP methods retain their
|
|
1156
|
+
existing semantics. The separate `@ksaa-nlp/gamehub-multiplayer` package owns
|
|
1157
|
+
Colyseus state, clock and recovery tokens.
|
|
1158
|
+
|
|
1159
|
+
Server `EndMatchPayload` adds optional version 2, per-seat scores, winner seat IDs
|
|
1160
|
+
and bounded metadata. The v2 room requires the v2 result shape and enriches it
|
|
1161
|
+
with trusted provenance. `ctx.endMatch` is a proposal, not a saved acknowledgement.
|
|
1162
|
+
Legacy endMatch payloads remain valid in legacy rooms.
|
|
1163
|
+
|
|
1164
|
+
SDK_VERSION, npm version and served JS/map are 4.3.0. The distribution gate is
|
|
1165
|
+
52 KiB raw / 12 KiB gzip (the raw increase covers v2 validation and game settings); runtime
|
|
1166
|
+
dependencies remain empty. Scanner version 3 includes requestMultiplayerLaunch,
|
|
1167
|
+
endMatch, seededPlayers and the static-only game-settings APIs; version-2 scans
|
|
1168
|
+
are stale after rebasing onto the game-settings release. A launch request
|
|
1169
|
+
observation is not successful admission; see the
|
|
1170
|
+
[usage report](../../specs/sdk-usage-report.md).
|
|
1171
|
+
|
|
1172
|
+
## Seeded participants (4.2.0)
|
|
1173
|
+
|
|
1174
|
+
`SeededPlayer` adds optional `kind: human|bot`, `seatId` and `peerId`. Missing kind means human for legacy hosts. V2 always supplies these fields; userId/seatId/peerId are the same opaque stable seat ID, never a bot/account credential. Bots do not connect or receive `onJoin`; the UGC bundle owns their legal moves using normal state/rules and `ctx.setTimeout`. All roster players, including bots, belong in endMatch scores. No realtime dependency is introduced. SDK Usage scanner 3 represents the widened data capability as `seededPlayers`: static identifiers are possible evidence; a trusted first UGC round-start acknowledgement confirms roster delivery. It does not prove a game consumed the field or that its bot algorithm acted. See the report specification.
|
|
1175
|
+
|
|
1176
|
+
## Lobby control v2 (4.3.0)
|
|
1177
|
+
|
|
1178
|
+
The optional capability `multiplayer.lobby.v2` enables game-owned lobby UI.
|
|
1179
|
+
`requestMultiplayerSession(request: MultiplayerSessionRequest)` sends the typed
|
|
1180
|
+
discriminated request to the host's POST `/multiplayer/session` bridge and returns
|
|
1181
|
+
`{success:true,data:MultiplayerLobbyState}` or `{success:false,error:{code,message,
|
|
1182
|
+
retryable}}`. Operations and their fields are defined in
|
|
1183
|
+
`types/multiplayer-session.ts`: create (type/passcode), join (code/name/type/
|
|
1184
|
+
passcode), ready (boolean), remove-bot (seatId), read/start/leave/rematch/add-bot.
|
|
1185
|
+
There are no caller-supplied game, session, host, profile, key or revision fields.
|
|
1186
|
+
The host binds these and the server enforces its normal admission/authority.
|
|
1187
|
+
Native/legacy hosts without the capability return `PROTOCOL_UNSUPPORTED`.
|
|
1188
|
+
|
|
1189
|
+
`onMultiplayerSessionChange(listener)` returns an unsubscribe function and
|
|
1190
|
+
immediately emits a detached snapshot, then trusted host pushes and successful
|
|
1191
|
+
request results. Callback exceptions are isolated and registrations unsubscribe
|
|
1192
|
+
independently. SDK validates bounded fields and copies only public roster, limits,
|
|
1193
|
+
phase/reason, invitation URLs and errors, never host credentials or URLs used for
|
|
1194
|
+
content/reservations. Invalid snapshots are ignored. `getBootstrap()` includes
|
|
1195
|
+
`multiplayerSession` (empty when absent) and `multiplayerEntry` (null or trusted
|
|
1196
|
+
initial create/join intent, code, seat type). New host pushes use
|
|
1197
|
+
`GAMEHUB_SDK_MULTIPLAYER_SESSION` and retain direct-parent/origin pinning.
|
|
1198
|
+
|
|
1199
|
+
Before a round exists, the bootstrap uses `mode:multiplayer_lobby` and null
|
|
1200
|
+
`multiplayerLaunch`. Both lobby capability and a launch suppress auth exchange
|
|
1201
|
+
and prohibit ordinary session creation/submission, even with a stale cached solo
|
|
1202
|
+
token. A loading round is a new pinned document with the existing launch contract;
|
|
1203
|
+
`requestMultiplayerLaunch()` semantics remain unchanged. In-flight lobby replies
|
|
1204
|
+
are fenced against a changed slug/launch. Hosts retain all storage and sockets
|
|
1205
|
+
remain in the separate adapter.
|
|
1206
|
+
|
|
1207
|
+
SDK Usage scanner 4 includes both new APIs, with Arabic admin/filter/CSV support.
|
|
1208
|
+
Successful validated host lobby requests observe `requestMultiplayerSession`;
|
|
1209
|
+
`onMultiplayerSessionChange` is static-only because delivered state does not prove
|
|
1210
|
+
a subscription. Observations do not prove admission or a started round.
|