Class: Network
WebSGNetworking.Network
Represents the networking methods available for sending and receiving data in a WebSG script.
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new Network()
Properties
onpeerentered
• onpeerentered: null
| (peer
: Peer
) => any
Callback for when a peer enters the world.
Param
The peer that entered the world.
Defined in
onpeerexited
• onpeerexited: null
| (peer
: Peer
) => any
Callback for when a peer exits the world.
Param
The peer that exited the world.
Defined in
Accessors
host
• get
host(): undefined
| Peer
The current host Peer in the world. This may change as peers enter and exit the world.
Returns
undefined
| Peer
Defined in
local
• get
local(): undefined
| Peer
The local user's Peer in the world. This will not be set until the user has entered the world and world.onenter is called
Returns
undefined
| Peer
Defined in
Methods
broadcast
▸ broadcast(message
, reliable?
): undefined
Broadcasts data to all connected clients.
Parameters
Name | Type | Description |
---|---|---|
message | string | ArrayBuffer | - |
reliable? | boolean | Whether or not the data should be sent reliably or unreliably. Defaults to true. |
Returns
undefined
Defined in
defineReplicator
▸ defineReplicator(factory
): Replicator
Defines a new replicator that can be used to spawn and despawn nodes
Parameters
Name | Type | Description |
---|---|---|
factory | () => Node | A function called whenever a new node is spawned. |
Returns
Defined in
listen
▸ listen(): NetworkListener
Creates a new $NetworkListener that can be used to listen for incoming messages from other peers.