@irtio/server 0.8.0 → 0.9.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/dist/index.d.ts +31 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -674,6 +674,21 @@ interface ClientInfo {
|
|
|
674
674
|
type TimerHandle = number;
|
|
675
675
|
interface Room<S extends AnySchema = AnySchema> {
|
|
676
676
|
readonly id: string;
|
|
677
|
+
/**
|
|
678
|
+
* The room's tracked state — the very object every handler already gets as its first argument.
|
|
679
|
+
*
|
|
680
|
+
* It is here for the one place that has a `room` and no `state` parameter: `physics.setup`.
|
|
681
|
+
* Static geometry that depends on what the room holds (a level chosen at create, a layout
|
|
682
|
+
* restored from a snapshot) had no way to read it, and the workaround was a module-level
|
|
683
|
+
* variable set by `onCreate` — which runs *after* setup on a fresh room, so it was empty
|
|
684
|
+
* exactly when it mattered.
|
|
685
|
+
*
|
|
686
|
+
* What it holds at setup time: on a wake that had to rebuild the world, the snapshot is already
|
|
687
|
+
* decoded, so restored state is fully readable. On a fresh room it is the schema's defaults with
|
|
688
|
+
* no entities: `onCreate` has not run yet. Do not reach for `room.physics` inside setup — the
|
|
689
|
+
* world being built is the one setup is holding.
|
|
690
|
+
*/
|
|
691
|
+
readonly state: State<S>;
|
|
677
692
|
/** Shareable URL (`?room=<id>`). */
|
|
678
693
|
readonly link: string;
|
|
679
694
|
readonly tick: number;
|
|
@@ -683,6 +698,12 @@ interface Room<S extends AnySchema = AnySchema> {
|
|
|
683
698
|
readonly clients: readonly ClientInfo[];
|
|
684
699
|
/** Seeded, recorded for replay. */
|
|
685
700
|
random(): number;
|
|
701
|
+
/**
|
|
702
|
+
* The resolved RNG seed: `options.seed` when given, otherwise derived from the room id.
|
|
703
|
+
* Stable for the room's whole life, survives hibernation. Use it directly for procedural
|
|
704
|
+
* generation that every client must be able to reproduce.
|
|
705
|
+
*/
|
|
706
|
+
readonly seed: number;
|
|
686
707
|
send(target: MessageTarget, bytes: Uint8Array): void;
|
|
687
708
|
/**
|
|
688
709
|
* D70: `room.messages.<name>.send(target, value)` — one of the shapes the schema declares,
|
|
@@ -709,6 +730,16 @@ interface Room<S extends AnySchema = AnySchema> {
|
|
|
709
730
|
call(clientId: string): ServerCallProxy<SchemaRpc<S>>;
|
|
710
731
|
/** Server → client void RPCs to every connected client. */
|
|
711
732
|
readonly broadcast: BroadcastProxy<SchemaRpc<S>>;
|
|
733
|
+
/**
|
|
734
|
+
* The same broadcast, minus the client(s) named — `room.broadcastExcept(ctx.clientId).hit({…})`.
|
|
735
|
+
*
|
|
736
|
+
* The thing it replaces: a `from` field on the payload, and a filter on receipt in every client.
|
|
737
|
+
* That shape sends the actor its own echo, costs a schema field per RPC, and gets the comparison
|
|
738
|
+
* wrong exactly once per game. Typed identically to `broadcast` — void client-direction RPCs
|
|
739
|
+
* only. An id that is not connected (or never existed) is skipped rather than refused, so
|
|
740
|
+
* "everyone except the player who just left" is safe to say.
|
|
741
|
+
*/
|
|
742
|
+
broadcastExcept(clientId: string | readonly string[]): BroadcastProxy<SchemaRpc<S>>;
|
|
712
743
|
/**
|
|
713
744
|
* D24: write a retained, addressable snapshot generation of this room right now and resolve
|
|
714
745
|
* with its save id. Like every promise-returning room API, the continuation runs as its own
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@irtio/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "irtio room-file API: defineRoom, handler and ctx types",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@irtio/schema": "0.
|
|
23
|
+
"@irtio/schema": "0.9.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@dimforge/rapier2d-compat": ">=0.20.0",
|