Skip to main content

Class: Session

Defined in: livelink.clients/livelink.js/sources/session/Session.ts:19

The browser SDK ships its own Session subclass, overriding the shared headless session: clients are resolved as the browser Client (which adds camera/viewer metadata), the client metadata carried by the video frames is dispatched to them, and the event map is extended with the (deprecated) viewport event.

Events SessionEvents

Extends

Constructors

Constructor

protected new Session(params: {
token: string;
session_info: SessionInfo;
created: boolean;
is_guest?: boolean;
}): Session;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:426

Create a new session.

Parameters

ParameterTypeDescription
params{ token: string; session_info: SessionInfo; created: boolean; is_guest?: boolean; }-
params.tokenstringThe authentication token. This token must have at least read access to the scene.
params.session_infoSessionInfoThe information about the session.
params.createdbooleanWhether the session has been created or found by the current client.
params.is_guest?boolean-

Returns

Session

Inherited from

SessionBase<Client>.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited from
inforeadonlySessionInfoundefinedThe information about the session.SessionBase.info
has_been_createdreadonlybooleanundefinedWhether the session has been created or joined by the current client.SessionBase.has_been_created
client_idpublicUUID | nullnullThe id of the client that is currently connected to the session.SessionBase.client_id
tokenreadonlystringundefinedThe authentication token.SessionBase.token
is_guestreadonlybooleanfalseWhether the authentication token is a guest token.SessionBase.is_guest

Accessors

scene_id

Get Signature

get scene_id(): UUID;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:356

The unique identifier of the scene the session is running.

Returns

UUID

Inherited from

SessionBase.scene_id;

session_id

Get Signature

get session_id(): UUID;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:363

The unique identifier of the session.

Returns

UUID

Inherited from

SessionBase.session_id;

client_ids

Get Signature

get client_ids(): UUID[];

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:370

The unique identifiers of all clients connected to the session.

Returns

UUID[]

Inherited from

SessionBase.client_ids;

clients

Get Signature

get clients(): ClientType[];

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:377

All the clients connected to the session.

Returns

ClientType[]

Inherited from

SessionBase.clients;

other_clients

Get Signature

get other_clients(): ClientType[];

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:384

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

Returns

ClientType[]

Inherited from

SessionBase.other_clients;

current_client

Get Signature

get current_client(): ClientType | null;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:391

The current client connected to the session.

Returns

ClientType | null

Inherited from

SessionBase.current_client;

Methods

addEventListener()

addEventListener<_EventName>(
event_name: _EventName,
listener: (event: SessionEvents[_EventName]) => void,
options?: boolean | AddEventListenerOptions): void;

Defined in: livelink.clients/livelink.js/sources/session/Session.ts:24

Register a listener for a session event. The browser session adds the (deprecated) viewport event on top of the shared SessionEvents map.

Type Parameters

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

Parameters

ParameterType
event_name_EventName
listener(event: SessionEvents[_EventName]) => void
options?boolean | AddEventListenerOptions

Returns

void

Overrides

SessionBase.addEventListener;

removeEventListener()

removeEventListener<_EventName>(
event_name: _EventName,
listener: (event: SessionEvents[_EventName]) => void,
options?: boolean | EventListenerOptions): void;

Defined in: livelink.clients/livelink.js/sources/session/Session.ts:35

Remove a previously registered session event listener.

Type Parameters

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

Parameters

ParameterType
event_name_EventName
listener(event: SessionEvents[_EventName]) => void
options?boolean | EventListenerOptions

Returns

void

Overrides

SessionBase.removeEventListener;

create()

static create<T>(this: T, params: {
scene_id: UUID;
token: string;
is_transient?: boolean;
options?: Record<string, boolean>;
}): Promise<{
info: SessionInfo;
has_been_created: boolean;
client_id: UUID | null;
token: string;
is_guest: boolean;
get scene_id(): UUID;
get session_id(): UUID;
get client_ids(): UUID[];
get clients(): ClientType[];
get other_clients(): ClientType[];
get current_client(): ClientType | null;
addEventListener: void;
removeEventListener: void;
isJoinable: boolean;
getClient: any;
evictClient: Promise<boolean>;
}>;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:133

Create a new session.

Type Parameters

Type Parameter
T extends { prototype: Session<any>; }

Parameters

ParameterTypeDescription
thisT-
params{ scene_id: UUID; token: string; is_transient?: boolean; options?: Record<string, boolean>; }-
params.scene_idUUIDThe unique identifier of the scene the session will launch.
params.tokenstringThe authentication token. This token must have at least read access to the scene.
params.is_transient?booleanWhether the session is transient. Transient sessions are temporary and changes are not saved.
params.options?Record<string, boolean>-

Returns

Promise<{ info: SessionInfo; has_been_created: boolean; client_id: UUID | null; token: string; is_guest: boolean; get scene_id(): UUID; get session_id(): UUID; get client_ids(): UUID[]; get clients(): ClientType[]; get other_clients(): ClientType[]; get current_client(): ClientType | null; addEventListener: void; removeEventListener: void; isJoinable: boolean; getClient: any; evictClient: Promise<boolean>; }>

A promise that resolves to the created session.

Throws

Error if the session could not be created.

Inherited from

SessionBase.create;

createFromInfo()

static createFromInfo<T>(this: T, params: {
session_info: SessionInfo;
token: string;
}): {
info: SessionInfo;
has_been_created: boolean;
client_id: UUID | null;
token: string;
is_guest: boolean;
get scene_id(): UUID;
get session_id(): UUID;
get client_ids(): UUID[];
get clients(): ClientType[];
get other_clients(): ClientType[];
get current_client(): ClientType | null;
addEventListener: void;
removeEventListener: void;
isJoinable: boolean;
getClient: any;
evictClient: Promise<boolean>;
};

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:181

Create a session instance from a session info, without creating or joining anything server-side.

Type Parameters

Type Parameter
T extends { prototype: Session<any>; }

Parameters

ParameterTypeDescription
thisT-
params{ session_info: SessionInfo; token: string; }-
params.session_infoSessionInfoThe information about the session.
params.tokenstringThe authentication token.

Returns

The session instance.

NameTypeDefault valueDescription
infoSessionInfo-The information about the session.
has_been_createdboolean-Whether the session has been created or joined by the current client.
client_idUUID | nullnullThe id of the client that is currently connected to the session.
tokenstring-The authentication token.
is_guestbooleanfalseWhether the authentication token is a guest token.
get scene_idUUID-The unique identifier of the scene the session is running.
get session_idUUID-The unique identifier of the session.
get client_idsUUID[]-The unique identifiers of all clients connected to the session.
get clientsClientType[]-All the clients connected to the session.
get other_clientsClientType[]-All the clients connected to the session except the current client.
get current_clientClientType | null-The current client connected to the session.
addEventListener()( event_name: _EventName, listener: (event: SessionEvents<any>[_EventName]) => void, options?: boolean | AddEventListenerOptions) => void-
removeEventListener()( event_name: _EventName, listener: (event: SessionEvents<any>[_EventName]) => void, options?: boolean | EventListenerOptions) => void-
isJoinable()() => boolean-Whether the session is joinable.
getClient()(params: { client_id: UUID; }) => any-Get a client by its unique identifier.
evictClient()(params: { client: UUID | Client; }) => Promise<boolean>-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.

Inherited from

SessionBase.createFromInfo;

list()

static list(params: {
scene_id: UUID;
token: string;
}): Promise<SessionInfo[]>;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:199

List all existing sessions running the specified scene.

Parameters

ParameterTypeDescription
params{ scene_id: UUID; token: string; }-
params.scene_idUUIDThe unique identifier of the scene the sessions must be running.
params.tokenstringThe authentication token.

Returns

Promise<SessionInfo[]>

A promise that resolves to the list of sessions running the scene, or to an empty list if the sessions could not be listed (a non-OK API response is treated as a legitimate impossibility to list the sessions of the scene, not as an error).

Inherited from

SessionBase.list;

find()

static find<T>(this: T, params: {
scene_id: UUID;
token: string;
session_selector: (__namedParameters: {
sessions: SessionInfo[];
}) => SessionInfo | null;
}): Promise<
| {
info: SessionInfo;
has_been_created: boolean;
client_id: UUID | null;
token: string;
is_guest: boolean;
get scene_id(): UUID;
get session_id(): UUID;
get client_ids(): UUID[];
get clients(): ClientType[];
get other_clients(): ClientType[];
get current_client(): ClientType | null;
addEventListener: void;
removeEventListener: void;
isJoinable: boolean;
getClient: any;
evictClient: Promise<boolean>;
}
| null>;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:227

Find an existing session running the specified scene.

Type Parameters

Type Parameter
T extends { prototype: Session<any>; }

Parameters

ParameterTypeDescription
thisT-
params{ scene_id: UUID; token: string; session_selector: (__namedParameters: { sessions: SessionInfo[]; }) => SessionInfo | null; }-
params.scene_idUUIDThe unique identifier of the scene the session must be running.
params.tokenstringThe authentication token. This token must have at least read access to the scene.
params.session_selector(__namedParameters: { sessions: SessionInfo[]; }) => SessionInfo | nullA callback that selects a session from a list of candidate sessions.

Returns

Promise< | { info: SessionInfo; has_been_created: boolean; client_id: UUID | null; token: string; is_guest: boolean; get scene_id(): UUID; get session_id(): UUID; get client_ids(): UUID[]; get clients(): ClientType[]; get other_clients(): ClientType[]; get current_client(): ClientType | null; addEventListener: void; removeEventListener: void; isJoinable: boolean; getClient: any; evictClient: Promise<boolean>; } | null>

A promise that resolves to the found session, or null if no session was found: no session is running the scene, the session selector selected none, or the sessions could not be listed (see Session.list).

Inherited from

SessionBase.find;

findById()

static findById<T>(this: T, params: {
session_id: UUID;
token: string;
}): Promise<
| {
info: SessionInfo;
has_been_created: boolean;
client_id: UUID | null;
token: string;
is_guest: boolean;
get scene_id(): UUID;
get session_id(): UUID;
get client_ids(): UUID[];
get clients(): ClientType[];
get other_clients(): ClientType[];
get current_client(): ClientType | null;
addEventListener: void;
removeEventListener: void;
isJoinable: boolean;
getClient: any;
evictClient: Promise<boolean>;
}
| null>;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:262

Find an existing session by its unique identifier.

Type Parameters

Type Parameter
T extends { prototype: Session<any>; }

Parameters

ParameterTypeDescription
thisT-
params{ session_id: UUID; token: string; }-
params.session_idUUIDThe unique identifier of the session to find.
params.tokenstringThe authentication token. This token must have at least read access to the scene.

Returns

Promise< | { info: SessionInfo; has_been_created: boolean; client_id: UUID | null; token: string; is_guest: boolean; get scene_id(): UUID; get session_id(): UUID; get client_ids(): UUID[]; get clients(): ClientType[]; get other_clients(): ClientType[]; get current_client(): ClientType | null; addEventListener: void; removeEventListener: void; isJoinable: boolean; getClient: any; evictClient: Promise<boolean>; } | null>

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

Inherited from

SessionBase.findById;

findByGuestToken()

static findByGuestToken<T>(this: T, params: {
guest_token: string;
}): Promise<
| {
info: SessionInfo;
has_been_created: boolean;
client_id: UUID | null;
token: string;
is_guest: boolean;
get scene_id(): UUID;
get session_id(): UUID;
get client_ids(): UUID[];
get clients(): ClientType[];
get other_clients(): ClientType[];
get current_client(): ClientType | null;
addEventListener: void;
removeEventListener: void;
isJoinable: boolean;
getClient: any;
evictClient: Promise<boolean>;
}
| null>;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:296

Find the session tied to a guest token.

Type Parameters

Type Parameter
T extends { prototype: Session<any>; }

Parameters

ParameterTypeDescription
thisT-
params{ guest_token: string; }-
params.guest_tokenstringThe guest token generated by the Generate Guest Token endpoint.

Returns

Promise< | { info: SessionInfo; has_been_created: boolean; client_id: UUID | null; token: string; is_guest: boolean; get scene_id(): UUID; get session_id(): UUID; get client_ids(): UUID[]; get clients(): ClientType[]; get other_clients(): ClientType[]; get current_client(): ClientType | null; addEventListener: void; removeEventListener: void; isJoinable: boolean; getClient: any; evictClient: Promise<boolean>; } | null>

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

Inherited from

SessionBase.findByGuestToken;

isJoinable()

isJoinable(): boolean;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:448

Whether the session is joinable.

Returns

boolean

Inherited from

SessionBase.isJoinable;

getClient()

getClient(params: {
client_id: UUID;
}): Client | null;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:498

Get a client by its unique identifier.

Parameters

ParameterTypeDescription
params{ client_id: UUID; }-
params.client_idUUIDThe unique identifier of the client to look for.

Returns

Client | null

The client or null if the client is not found.

Inherited from

SessionBase.getClient;

evictClient()

evictClient(params: {
client: UUID | Client;
}): Promise<boolean>;

Defined in: livelink.clients/livelink.base/sources/session/Session.ts:516

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

ParameterTypeDescription
params{ client: UUID | Client; }-
params.clientUUID | ClientThe 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.

Inherited from

SessionBase.evictClient;