@relu-interactives/spatial-ecs
@relu-interactives/spatial-ecs / index / NetworkHandle
Interface: NetworkHandle ​
Defined in: network/types.ts:207
A Behaviour's view of the shared world: this.network, null in a single-player run.
Properties ​
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
connected | readonly | boolean | - | network/types.ts:208 |
sessionId | readonly | string | This client's id in the room. | network/types.ts:210 |
isHost | readonly | boolean | Whether this client simulates the scene's shared objects. | network/types.ts:212 |
isOwner | readonly | boolean | Whether this client simulates this entity. | network/types.ts:214 |
players | readonly | string[] | Everyone in the room, by session id. | network/types.ts:216 |
voice | readonly | VoiceHandle | null | Voice chat, when the project has it on. | network/types.ts:218 |
colocation | readonly | ColocationHandle | null | Lining up players in one room, when the scene has colocation on. | network/types.ts:220 |
holder | readonly | string | Who is holding this entity right now, or empty. | network/types.ts:239 |
Methods ​
playerName() ​
playerName(id): string;Defined in: network/types.ts:222
A player's name: what they set, else "Player 2" and so on.
Parameters ​
| Parameter | Type |
|---|---|
id | string |
Returns ​
string
setName() ​
setName(name): void;Defined in: network/types.ts:224
The name others see over this player's head.
Parameters ​
| Parameter | Type |
|---|---|
name | string |
Returns ​
void
send() ​
send(name, payload?): void;Defined in: network/types.ts:226
Send to the room. Others hear it in onMessage, unless a server hook keeps it.
Parameters ​
| Parameter | Type |
|---|---|
name | string |
payload? | unknown |
Returns ​
void
onMessage() ​
onMessage(name, handler): () => void;Defined in: network/types.ts:228
Listen for a message. Returns the way to stop.
Parameters ​
| Parameter | Type |
|---|---|
name | string |
handler | (payload, from) => void |
Returns ​
() => void
playSlot() ​
playSlot(id, options?): boolean;Defined in: network/types.ts:233
Play a sound-bank slot here and for everyone in the room. Returns whether it sounded: a slot's chance and cooldown can keep it quiet, and then no one hears it.
Parameters ​
| Parameter | Type |
|---|---|
id | string |
options? | PlaySlotOptions |
Returns ​
boolean
spawn() ​
spawn(prefab, options?): void;Defined in: network/types.ts:235
Spawn a prefab everyone sees, owned by this client.
Parameters ​
| Parameter | Type |
|---|---|
prefab | | string | { path: string; } |
options? | NetSpawnOptions |
Returns ​
void
despawn() ​
despawn(entityId?): void;Defined in: network/types.ts:237
Remove a shared entity this client owns (this one by default).
Parameters ​
| Parameter | Type |
|---|---|
entityId? | number |
Returns ​
void
take() ​
take(): boolean;Defined in: network/types.ts:245
Ask to move this scene object yourself, as a grab does: it becomes yours once the room agrees. Returns false when it can't be asked for, such as a spawned object or one someone else is holding.
Returns ​
boolean
drop() ​
drop(): void;Defined in: network/types.ts:247
Stop holding it. It stays yours until someone else takes it.
Returns ​
void
setProp() ​
setProp(key, value): void;Defined in: network/types.ts:249
Change a shared value on this entity. Only its owner can.
Parameters ​
| Parameter | Type |
|---|---|
key | string |
value | NetValue |
Returns ​
void
getProp() ​
getProp(key): NetValue | undefined;Defined in: network/types.ts:250
Parameters ​
| Parameter | Type |
|---|---|
key | string |
Returns ​
NetValue | undefined

