True when connected to a room via a regular url, otherwise (when using a view only url) false indicating that the user should not be able to modify the scene
The connection id of the local user - it is given by the networking backend and can not be changed
Latency to currently connected backend server
The name of the room the user is currently connected to
The view id of the room the user is currently connected to.
The current server url that the networking backend is connected to (e.g. the url of the websocket server)
True when connected to the networking backend
Returns true if the networking backend is in debug mode.
To see all networking messages in the console use ?debugnet
in the url
True if connected to a networked room. Use the joinRoom function or a SyncedRoom
component
Experimental: networking via peerjs
Use to start listening to networking events.
To unsubscribe from events use the stopListen
method.
See the example below for typical usage:
// Make sure to unsubscribe from events when the component is disabled
export class MyComponent extends Behaviour {
onEnable() {
this.connection.beginListen("joined-room", this.onJoinedRoom)
}
onDisable() {
this.connection.stopListen("joined-room", this.onJoinedRoom)
}
onJoinedRoom = () => {
console.log("I joined a networked room")
}
}
Returns a url that can be shared with others to view the current room in view only mode.
This is useful for sharing a room with others without allowing them to modify the scene.
Use connection.allowEditing
to check if the current room is in view only mode.
Send a binary message to the server (broadcasted to all connected users)
Use to stop listening to networking events
To subscribe to events use the beginListen
method.
See the example below for typical usage:
// Make sure to unsubscribe from events when the component is disabled
export class MyComponent extends Behaviour {
onEnable() {
this.connection.beginListen("joined-room", this.onJoinedRoom)
}
onDisable() {
this.connection.stopListen("joined-room", this.onJoinedRoom)
}
onJoinedRoom = () => {
console.log("I joined a networked room")
}
}
Main class to communicate with the networking backend
Link
https://engine.needle.tools/docs/networking.html