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.
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",
});
Examples
Document | Description |
---|---|
Complete Example | - |
Other
Name | Description |
---|---|
session | The session associated with this Livelink instance. |
scene | The scene the current session is running. |
default_decoded_frame_consumer | - |
activity_watcher | - |
latency | - |
viewports | - |
devices | - |
- | |
- | |
start | Start a new session on the specified scene. |
join_or_start | Try to join an existing session on the specified scene, if none is found fallback to starting a new one. |
join | Join an existing session. |
disconnect | Disconnect from the server and release all local resources. |
addViewports | Add viewports to the remote rendering surface. |
removeViewport | Remove viewports from the remote rendering surface. |
configureRemoteServer | Configure the remote server with the desired codec. |
isConfigured | Check if the client is configured. |
setEncodedFrameConsumer | Set the encoded frame consumer. |
startStreaming | Start streaming the viewports from the server. |
startSimulation | Send a script event to the server to start the simulation. |
pauseSimulation | Send a script event to the server to pause the simulation. |
stopSimulation | Send a script event to the server to stop the simulation. |
sendSkeletonPose | Send a partial skeleton pose targeting a specific animation controller. |
configureHeadlessClient | - |
Other
session
readonly session: Session;
Defined in: livelink.js/sources/Livelink.ts:245
The session associated with this Livelink instance.
scene
readonly scene: Scene;
Defined in: livelink.js/sources/Livelink.ts:250
The scene the current session is running.
default_decoded_frame_consumer
Get Signature
get default_decoded_frame_consumer(): DecodedFrameConsumer
Defined in: livelink.js/sources/Livelink.ts:303
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:311
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:318
The latency of the connection in milliseconds.
Returns
number
viewports
Get Signature
get viewports(): Viewport[]
Defined in: livelink.js/sources/Livelink.ts:325
The viewports used to render the scene for the current client.
Returns
Viewport
[]
devices
Get Signature
get devices(): Readonly<{
mouse: Mouse;
keyboard: Keyboard;
gamepad: Gamepad;
}>
Defined in: livelink.js/sources/Livelink.ts:503
Experimental
Returns
Readonly
<{
mouse
: Mouse
;
keyboard
: Keyboard
;
gamepad
: Gamepad
;
}>
TO_REMOVE__setReadyCallback()
TO_REMOVE__setReadyCallback(callback: () => void): void
Defined in: livelink.js/sources/Livelink.ts:108
Parameters
Parameter | Type |
---|---|
callback | () => void |
Returns
void
Deprecated
TO_REMOVE__startIfReady()
TO_REMOVE__startIfReady(): void
Defined in: livelink.js/sources/Livelink.ts:115
Returns
void
Deprecated
start()
static start(params: {
scene_id: UUID;
token: string;
is_transient: boolean;
}): Promise<Livelink>
Defined in: livelink.js/sources/Livelink.ts:154
Start a new session on the specified scene.
Parameters
Parameter | Type | Description |
---|---|---|
params | { scene_id : UUID ; token : string ; is_transient : 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. |
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;
}): Promise<Livelink>
Defined in: livelink.js/sources/Livelink.ts:186
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 ; } | |
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. |
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;
}): Promise<Livelink>
Defined in: livelink.js/sources/Livelink.ts:235
Join an existing session.
Parameters
Parameter | Type | Description |
---|---|---|
params | { session : Session ; } | |
params.session | Session | The session to join |
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:349
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:377
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:388
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:403
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:424
Check if the client is configured.
Returns
boolean
setEncodedFrameConsumer()
setEncodedFrameConsumer(__namedParameters: {
encoded_frame_consumer: EncodedFrameConsumer;
}): Promise<void>
Defined in: livelink.js/sources/Livelink.ts:431
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:449
Start streaming the viewports from the server.
Returns
void
startSimulation()
startSimulation(): void
Defined in: livelink.js/sources/Livelink.ts:462
Send a script event to the server to start the simulation.
Returns
void
pauseSimulation()
pauseSimulation(): void
Defined in: livelink.js/sources/Livelink.ts:469
Send a script event to the server to pause the simulation.
Returns
void
stopSimulation()
stopSimulation(): void
Defined in: livelink.js/sources/Livelink.ts:476
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:487
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
configureHeadlessClient()
configureHeadlessClient(): Promise<ClientConfigResponse>
Defined in: livelink.js/sources/Livelink.ts:514
Experimental
Returns
Promise
<ClientConfigResponse
>