Class: Livelink
Defined in: livelink.js/sources/Livelink.ts:93
This class represents the Livelink connection between the client and the 3dverse server holding the session. It holds access to the actual socket connection as well as a client local representation of the rendered scene.
This class is not directly instantiable, you need to use the provided static functions to create an instance:
- Livelink.start: to start a new session.
- Livelink.join: to join an exisiting session.
- Livelink.join_or_start: to try joining an existing session if one if found or fallback to starting a new one otherwise.
Connection lifecycle
The connection lifecycle is as follows:
- Livelink.start, Livelink.join or Livelink.join_or_start to create a new Livelink instance.
- Livelink.configureRemoteServer to configure the remote server with the desired codec.
- Livelink.addViewports to add the viewports to the remote rendering surface so that the server knows the size of the encoded frames to send.
- Livelink.setEncodedFrameConsumer to set the encoded frame consumer that will process the encoded frames received from the server.
- Livelink.startStreaming to start streaming the remotely rendered frames.
Input devices
Input devices can be accessed from the Livelink instance using the Livelink.devices property. They can be activated and deactivated using the appropriate methods. An active input device will automatically send its state as it changes to the server.
Session management
Starting a new session:
const instance = await Livelink.start({
scene_id: "00000000-0000-0000-0000-000000000000",
token: "authentication-token",
});
Joining an existing session:
const session = await Session.find({
scene_id: "00000000-0000-0000-0000-000000000000",
token: "authentication-token",
});
const instance = await Livelink.join({ session });
Joining an existing session or starting a new one if none is found:
const instance = await Livelink.join_or_start({
scene_id: "00000000-0000-0000-0000-000000000000",
token: "authentication-token",
});
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
session | readonly | Session | The session associated with this Livelink instance. |
scene | readonly | Scene | The scene the current session is running. |
Accessors
default_decoded_frame_consumer
Get Signature
get default_decoded_frame_consumer(): DecodedFrameConsumer;
Defined in: livelink.js/sources/Livelink.ts:291
The default internal implementation of the DecodedFrameConsumer interface.
If no custom decoded frame consumer is needed, this can be passed to instanciate EncodedFrameConsumer implementations.
Returns
activity_watcher
Get Signature
get activity_watcher(): ActivityWatcher;
Defined in: livelink.js/sources/Livelink.ts:299
The activity watcher disconnects the session if no activity is detected for a certain amount of time.
Returns
latency
Get Signature
get latency(): number;
Defined in: livelink.js/sources/Livelink.ts:306
The latency of the connection in milliseconds.
Returns
number
frame_timestamp
Get Signature
get frame_timestamp(): number;
Defined in: livelink.js/sources/Livelink.ts:313
The renderer timestamp in miliseconds of the latest received frame.
Returns
number
frame_dt
Get Signature
get frame_dt(): number;
Defined in: livelink.js/sources/Livelink.ts:320
The delta time in miliseconds between the two latest received frames based on renderer timestamp.
Returns
number
viewports
Get Signature
get viewports(): Viewport[];
Defined in: livelink.js/sources/Livelink.ts:327
The viewports used to render the scene for the current client.
Returns
Viewport[]
devices
Get Signature
get devices(): Readonly<{
mouse: Mouse;
keyboard: Keyboard;
gamepads_registry: GamepadsRegistry;
}>;
Defined in: livelink.js/sources/Livelink.ts:514
Experimental
Returns
Readonly<{
mouse: Mouse;
keyboard: Keyboard;
gamepads_registry: GamepadsRegistry;
}>
Methods
start()
static start(params: {
scene_id: UUID;
token: string;
is_transient?: boolean;
is_headless?: boolean;
}): Promise<Livelink>;
Defined in: livelink.js/sources/Livelink.ts:113
Start a new session on the specified scene.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { scene_id: UUID; token: string; is_transient?: boolean; is_headless?: boolean; } | |
params.scene_id | UUID | The id of the scene to start |
params.token | string | The public access token or the user token which must have at least read access to the scene |
params.is_transient? | boolean | Whether the session should be transient or not. |
params.is_headless? | boolean | Whether the client should be headless or not. |
Returns
Promise<Livelink>
A promise to a Livelink instance holding a session with the specified scene
Throws
If the session could not be started
join_or_start()
static join_or_start(params: {
scene_id: UUID;
token: string;
session_selector?: (__namedParameters: {
sessions: SessionInfo[];
}) => null | SessionInfo;
is_transient?: boolean;
is_headless?: boolean;
}): Promise<Livelink>;
Defined in: livelink.js/sources/Livelink.ts:148
Try to join an existing session on the specified scene, if none is found fallback to starting a new one.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { scene_id: UUID; token: string; session_selector?: (__namedParameters: { sessions: SessionInfo[]; }) => null | SessionInfo; is_transient?: boolean; is_headless?: boolean; } | |
params.scene_id | UUID | The id of the scene to join |
params.token | string | The public access token or the user token which must have at least read access to the scene |
params.session_selector? | (__namedParameters: { sessions: SessionInfo[]; }) => null | SessionInfo | A function to select the session to join among the list of available sessions. If no session is found, the function should return null to fallback to starting a new session. |
params.is_transient? | boolean | Whether the session should be transient or not. |
params.is_headless? | boolean | Whether the client should be headless or not. |
Returns
Promise<Livelink>
A promise to a Livelink instance holding a session with the specified scene
Throws
If the session could not be joined or started
join()
static join(params: {
session: Session;
is_headless?: boolean;
}): Promise<Livelink>;
Defined in: livelink.js/sources/Livelink.ts:202
Join an existing session.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { session: Session; is_headless?: boolean; } | |
params.session | Session | The session to join |
params.is_headless? | boolean | Whether the client should be headless or not. |
Returns
Promise<Livelink>
A promise to a Livelink instance holding the specified session
Throws
If the session could not be joined
disconnect()
disconnect(): Promise<void>;
Defined in: livelink.js/sources/Livelink.ts:351
Disconnect from the server and release all local resources.
Note that the session is not closed, it can be reconnected later.
Returns
Promise<void>
addViewports()
addViewports(params: {
viewports: Viewport[];
}): void;
Defined in: livelink.js/sources/Livelink.ts:379
Add viewports to the remote rendering surface.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { viewports: Viewport[]; } | |
params.viewports | Viewport[] | The viewports to add. |
Returns
void
removeViewport()
removeViewport(params: {
viewport: Viewport;
}): void;
Defined in: livelink.js/sources/Livelink.ts:390
Remove viewports from the remote rendering surface.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { viewport: Viewport; } | |
params.viewport | Viewport | The viewport to remove. |
Returns
void
configureRemoteServer()
configureRemoteServer(params: {
codec?: CodecType;
}): Promise<ClientConfigResponse>;
Defined in: livelink.js/sources/Livelink.ts:405
Configure the remote server with the desired codec.
The viewports must have been added using Livelink.addViewports before calling this method.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { codec?: CodecType; } | |
params.codec? | CodecType | The codec to use for encoding the frames. |
Returns
Promise<ClientConfigResponse>
A promise to the client configuration response.
isConfigured()
isConfigured(): boolean;
Defined in: livelink.js/sources/Livelink.ts:426
Check if the client is configured.
Returns
boolean
setEncodedFrameConsumer()
setEncodedFrameConsumer(__namedParameters: {
encoded_frame_consumer: EncodedFrameConsumer;
}): Promise<void>;
Defined in: livelink.js/sources/Livelink.ts:433
Set the encoded frame consumer.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { encoded_frame_consumer: EncodedFrameConsumer; } |
__namedParameters.encoded_frame_consumer | EncodedFrameConsumer |
Returns
Promise<void>
startStreaming()
startStreaming(): void;
Defined in: livelink.js/sources/Livelink.ts:451
Start streaming the viewports from the server.
Returns
void
startSimulation()
startSimulation(): void;
Defined in: livelink.js/sources/Livelink.ts:473
Send a script event to the server to start the simulation.
Returns
void
pauseSimulation()
pauseSimulation(): void;
Defined in: livelink.js/sources/Livelink.ts:480
Send a script event to the server to pause the simulation.
Returns
void
stopSimulation()
stopSimulation(): void;
Defined in: livelink.js/sources/Livelink.ts:487
Send a script event to the server to stop the simulation.
Returns
void
sendSkeletonPose()
sendSkeletonPose(params: {
controller: Entity;
partial_pose: SkeletonPartialPose;
}): void;
Defined in: livelink.js/sources/Livelink.ts:498
Send a partial skeleton pose targeting a specific animation controller.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { controller: Entity; partial_pose: SkeletonPartialPose; } | |
params.controller | Entity | The entity having the animation controller component. |
params.partial_pose | SkeletonPartialPose | The partial pose to send. |
Returns
void
startHeadlessClient()
startHeadlessClient(): Promise<void>;
Defined in: livelink.js/sources/Livelink.ts:525
Experimental
Returns
Promise<void>
TO_REMOVE__setReadyCallback()
TO_REMOVE__setReadyCallback(callback: () => void): void;
Defined in: livelink.js/sources/Livelink.ts:776
Parameters
| Parameter | Type |
|---|---|
callback | () => void |
Returns
void
Deprecated
TO_REMOVE__startIfReady()
TO_REMOVE__startIfReady(): void;
Defined in: livelink.js/sources/Livelink.ts:783
Returns
void