@genex-ai/multiplayer 0.10.2 → 0.12.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 +2 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +3 -0
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,8 @@ for (const [id, p] of room.players) {
|
|
|
65
65
|
|
|
66
66
|
Remote players glide instead of teleporting between network updates — see **[Smoothing remote players](#smoothing-remote-players)**.
|
|
67
67
|
|
|
68
|
+
Each player also carries `p.avatarUrl` — the VRM avatar that player picked on their genex profile (guests get a per-session pick), verified server-side from their identity token so it can't be spoofed. Render each player's own look with it (e.g. `loadVrm(p.avatarUrl || "./assets/avatar.vrm")` in a VRM-lane game); it's `''` when unknown (older relay/API), so always keep a bundled fallback. Don't put an avatar URL in your `me.set` state — this field replaces that.
|
|
69
|
+
|
|
68
70
|
## `shared` — shared room state
|
|
69
71
|
|
|
70
72
|
A key/value store (any JSON) synced to everyone. Use for world state, scores, the current round, etc.
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ type ConnectOptions = {
|
|
|
9
9
|
/** Regional relay urls (pass `getColyseusUrls()`) — the SDK pings each and connects to the
|
|
10
10
|
* lowest-latency one; a single entry just connects. */
|
|
11
11
|
urls: string[];
|
|
12
|
+
/** Cross-region invite override: connect to THIS exact relay url, skipping latency selection. Two
|
|
13
|
+
* players are only in the same room if they share one region's relay, so an invitee must follow the
|
|
14
|
+
* inviter's region (carried in the invite) instead of picking its own nearest. Omit for normal
|
|
15
|
+
* nearest-region play. */
|
|
16
|
+
url?: string;
|
|
12
17
|
/** Game id — everyone who passes the same id shares a room; different ids are
|
|
13
18
|
* fully isolated. Use your project slug (or any stable per-game string). */
|
|
14
19
|
room: string;
|
|
@@ -32,6 +37,11 @@ type ConnectOptions = {
|
|
|
32
37
|
type PlayerView<TState> = {
|
|
33
38
|
id: string;
|
|
34
39
|
name: string;
|
|
40
|
+
/** This player's verified VRM avatar URL (the avatar they picked on their
|
|
41
|
+
* genex profile; guests get a per-session pick). Server-set from the embed
|
|
42
|
+
* token — cannot be spoofed. `''` when unknown (old relay/API). Load it for
|
|
43
|
+
* the player's visual; fall back to your bundled model when empty. */
|
|
44
|
+
avatarUrl: string;
|
|
35
45
|
/** Transport is live now. False while this reserved seat is inside reconnect grace. */
|
|
36
46
|
connected: boolean;
|
|
37
47
|
/** RENDER ONLY — for remote players this is **auto-smoothed** (interpolated) and delayed;
|
|
@@ -277,6 +287,9 @@ type Matchmaking<TState extends Record<string, unknown>> = {
|
|
|
277
287
|
type MatchmakeOptions = {
|
|
278
288
|
/** Regional relay urls (pass `getColyseusUrls()`) — pings each, connects to the lowest-latency one. */
|
|
279
289
|
urls: string[];
|
|
290
|
+
/** Cross-region override: matchmake on THIS exact relay url, skipping latency selection — an invitee
|
|
291
|
+
* follows the inviter's region so both land on the same relay. Omit for normal nearest-region play. */
|
|
292
|
+
url?: string;
|
|
280
293
|
/** Game id (your project slug/id) — isolates this game's matchmaking. */
|
|
281
294
|
room: string;
|
|
282
295
|
name?: string;
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ var STATE_SNAP_MSG = "__state:snap";
|
|
|
28
28
|
var OBJECT_SNAP_MSG = "__object:snap";
|
|
29
29
|
var MP_PROTOCOL = 2;
|
|
30
30
|
async function relayClient(opts) {
|
|
31
|
+
if (opts.url) return new Client(opts.url);
|
|
31
32
|
if (opts.urls.length > 1) return Client.selectByLatency(opts.urls);
|
|
32
33
|
const url = opts.urls[0];
|
|
33
34
|
if (!url) throw new Error("genex multiplayer: `urls` must contain at least one relay URL");
|
|
@@ -735,6 +736,8 @@ function attachSession(client, initialRoom) {
|
|
|
735
736
|
out.set(id, {
|
|
736
737
|
id,
|
|
737
738
|
name: p.name,
|
|
739
|
+
avatarUrl: p.avatarUrl ?? "",
|
|
740
|
+
// old relay schemas did not carry the field
|
|
738
741
|
connected: p.connected !== false,
|
|
739
742
|
// old relay schemas did not carry the field
|
|
740
743
|
state,
|
package/dist/schema.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ declare const PlayerState: _colyseus_schema.SchemaWithExtendsConstructor<{
|
|
|
6
6
|
data: "string";
|
|
7
7
|
epoch: "number";
|
|
8
8
|
connected: "boolean";
|
|
9
|
+
avatarUrl: "string";
|
|
9
10
|
}, _colyseus_schema.AssignableProps<_colyseus_schema.InferSchemaInstanceType<{
|
|
10
11
|
name: "string";
|
|
11
12
|
data: "string";
|
|
12
13
|
epoch: "number";
|
|
13
14
|
connected: "boolean";
|
|
15
|
+
avatarUrl: "string";
|
|
14
16
|
}>>, typeof _colyseus_schema.Schema>;
|
|
15
17
|
type PlayerState = SchemaType<typeof PlayerState>;
|
|
16
18
|
declare const RoomState: _colyseus_schema.SchemaWithExtendsConstructor<{
|
|
@@ -20,17 +22,20 @@ declare const RoomState: _colyseus_schema.SchemaWithExtendsConstructor<{
|
|
|
20
22
|
data: "string";
|
|
21
23
|
epoch: "number";
|
|
22
24
|
connected: "boolean";
|
|
25
|
+
avatarUrl: "string";
|
|
23
26
|
}, _colyseus_schema.AssignableProps<_colyseus_schema.InferSchemaInstanceType<{
|
|
24
27
|
name: "string";
|
|
25
28
|
data: "string";
|
|
26
29
|
epoch: "number";
|
|
27
30
|
connected: "boolean";
|
|
31
|
+
avatarUrl: "string";
|
|
28
32
|
}>>, typeof _colyseus_schema.Schema>;
|
|
29
33
|
default: MapSchema<_colyseus_schema.InferSchemaInstanceType<{
|
|
30
34
|
name: "string";
|
|
31
35
|
data: "string";
|
|
32
36
|
epoch: "number";
|
|
33
37
|
connected: "boolean";
|
|
38
|
+
avatarUrl: "string";
|
|
34
39
|
}>, string>;
|
|
35
40
|
};
|
|
36
41
|
shared: {
|
|
@@ -44,17 +49,20 @@ declare const RoomState: _colyseus_schema.SchemaWithExtendsConstructor<{
|
|
|
44
49
|
data: "string";
|
|
45
50
|
epoch: "number";
|
|
46
51
|
connected: "boolean";
|
|
52
|
+
avatarUrl: "string";
|
|
47
53
|
}, _colyseus_schema.AssignableProps<_colyseus_schema.InferSchemaInstanceType<{
|
|
48
54
|
name: "string";
|
|
49
55
|
data: "string";
|
|
50
56
|
epoch: "number";
|
|
51
57
|
connected: "boolean";
|
|
58
|
+
avatarUrl: "string";
|
|
52
59
|
}>>, typeof _colyseus_schema.Schema>;
|
|
53
60
|
default: MapSchema<_colyseus_schema.InferSchemaInstanceType<{
|
|
54
61
|
name: "string";
|
|
55
62
|
data: "string";
|
|
56
63
|
epoch: "number";
|
|
57
64
|
connected: "boolean";
|
|
65
|
+
avatarUrl: "string";
|
|
58
66
|
}>, string>;
|
|
59
67
|
};
|
|
60
68
|
shared: {
|
package/dist/schema.js
CHANGED
|
@@ -9,7 +9,12 @@ var PlayerState = schema(
|
|
|
9
9
|
epoch: "number",
|
|
10
10
|
// Seat presence is distinct from connectivity: a dropped player keeps the
|
|
11
11
|
// seat during reconnection grace but flips connected=false immediately.
|
|
12
|
-
connected: "boolean"
|
|
12
|
+
connected: "boolean",
|
|
13
|
+
// The player's verified VRM avatar URL (AG-804) — set by the relay from the
|
|
14
|
+
// embed token, never client-writable. '' = none (old API / empty library).
|
|
15
|
+
// NEW FIELDS GO AFTER THIS ONE: @colyseus/schema keeps old clients decoding
|
|
16
|
+
// only when fields are appended at the end, never inserted or reordered.
|
|
17
|
+
avatarUrl: "string"
|
|
13
18
|
},
|
|
14
19
|
"PlayerState"
|
|
15
20
|
);
|