Skip to main content

Session

@3dverse/livelink v0.8.10


@3dverse/livelink / Session

Class: Session

Defined in: livelink.js/sources/session/Session.ts:64

A session running a scene.

A session is a running instance of a 3dverse server rendering a scene that can be joined by multiple clients.

A session can be transient or not. A transient session is temporary and changes made to the entities in the scene are not saved.

Usage

This class is not meant to be instantiated directly. Use the static methods to create or find an existing session.

A session can be created or joined:

Authentication

To create or find a session, you need a valid authentication token that has at least read access to the scene the session will use.

See: https://docs.3dverse.com/api/#tag/User-Authentication/operation/generateUserToken

Events

  • on-disconnected - Fired when the session is disconnected.
  • client-joined - Fired when a client joins the session.
  • client-left - Fired when a client leaves the session.

Extends

Implements

Properties

info

readonly info: SessionInfo

Defined in: livelink.js/sources/session/Session.ts:180

The information about the session.


has_been_created

readonly has_been_created: boolean

Defined in: livelink.js/sources/session/Session.ts:185

Whether the session has been created or joined by the current client.


client_id

client_id: null | UUID = null

Defined in: livelink.js/sources/session/Session.ts:190

The id of the client that is currently connected to the session.

Implementation of

SessionInterface.client_id


token

readonly token: string

Defined in: livelink.js/sources/session/Session.ts:195

The authentication token.

Accessors

scene_id

Get Signature

get scene_id(): UUID

Defined in: livelink.js/sources/session/Session.ts:220

The unique identifier of the scene the session is running.

Returns

UUID


session_id

Get Signature

get session_id(): UUID

Defined in: livelink.js/sources/session/Session.ts:227

The unique identifier of the session.

Returns

UUID


client_ids

Get Signature

get client_ids(): UUID[]

Defined in: livelink.js/sources/session/Session.ts:234

The unique identifiers of all clients connected to the session.

Returns

UUID[]


clients

Get Signature

get clients(): Client[]

Defined in: livelink.js/sources/session/Session.ts:241

All the clients connected to the session.

Returns

Client[]


other_clients

Get Signature

get other_clients(): Client[]

Defined in: livelink.js/sources/session/Session.ts:248

All the clients connected to the session except the current client.

Returns

Client[]


current_client

Get Signature

get current_client(): null | Client

Defined in: livelink.js/sources/session/Session.ts:255

The current client connected to the session.

Returns

null | Client

Methods

addEventListener()

addEventListener<_EventName>(event_name, listener, options?): void

Defined in: livelink.js/sources/TypedEventTarget.ts:10

Type Parameters

_EventName extends "TO_REMOVE__viewports-added" | "on-disconnected" | "on-inactivity-warning" | "on-activity-detected" | "on-client-joined" | "on-client-left"

Parameters

event_name

_EventName

listener

(event) => void

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

TypedEventTarget.addEventListener


removeEventListener()

removeEventListener<_EventName>(event_name, listener, options?): void

Defined in: livelink.js/sources/TypedEventTarget.ts:21

Type Parameters

_EventName extends "TO_REMOVE__viewports-added" | "on-disconnected" | "on-inactivity-warning" | "on-activity-detected" | "on-client-joined" | "on-client-left"

Parameters

event_name

_EventName

listener

(event) => void

options?

boolean | EventListenerOptions

Returns

void

Inherited from

TypedEventTarget.removeEventListener


create()

static create(params): Promise<Session>

Defined in: livelink.js/sources/session/Session.ts:77

Create a new session.

Parameters

params
scene_id

UUID

The unique identifier of the scene the session will launch.

token

string

The authentication token. This token must have at least read access to the scene.

is_transient

boolean

Whether the session is transient. Transient sessions are temporary and changes are not saved.

Returns

Promise<Session>

A promise that resolves to the created session.

Throws

Error if the session could not be created.


find()

static find(params): Promise<null | Session>

Defined in: livelink.js/sources/session/Session.ts:122

Find an existing session running the specified scene.

Parameters

params
scene_id

UUID

The unique identifier of the scene the session must be running.

token

string

The authentication token. This token must have at least read access to the scene.

session_selector

(__namedParameters) => null | SessionInfo

A callback that selects a session from a list of candidate sessions.

Returns

Promise<null | Session>

A promise that resolves to the found session or null if no session was found or if no session was selected by the session selector.


findById()

static findById(params): Promise<null | Session>

Defined in: livelink.js/sources/session/Session.ts:160

Find an existing session by its unique identifier.

Parameters

params
session_id

UUID

The unique identifier of the session to find.

token

string

The authentication token. This token must have at least read access to the scene.

Returns

Promise<null | Session>

A promise that resolves to the found session or null if no session was found.


isJoinable()

isJoinable(): boolean

Defined in: livelink.js/sources/session/Session.ts:302

Whether the session is joinable.

Returns

boolean


getClient()

getClient(params): null | Client

Defined in: livelink.js/sources/session/Session.ts:355

Get a client by its unique identifier.

Parameters

params
client_id

UUID

The unique identifier of the client to look for.

Returns

null | Client

The client or null if the client is not found.


evictClient()

evictClient(params): Promise<boolean>

Defined in: livelink.js/sources/session/Session.ts:373

Evict a client from the session.

The client will be disconnected.

The token used to create the session must have manage access to the scene.

Note that nothing prevents the client from reconnecting while the session is still running.

Parameters

params
client

UUID | Client

The client to evict, either a Client object or the unique identifier of the client.

Returns

Promise<boolean>

A promise that resolves to true if the client was evicted, false otherwise.