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
Session<Client>
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
| Parameter | Type | Description |
|---|---|---|
params | { token: string; session_info: SessionInfo; created: boolean; is_guest?: boolean; } | - |
params.token | string | The authentication token. This token must have at least read access to the scene. |
params.session_info | SessionInfo | The information about the session. |
params.created | boolean | Whether the session has been created or found by the current client. |
params.is_guest? | boolean | - |
Returns
Session
Inherited from
SessionBase<Client>.constructor
Properties
| Property | Modifier | Type | Default value | Description | Inherited from |
|---|---|---|---|---|---|
info | readonly | SessionInfo | undefined | The information about the session. | SessionBase.info |
has_been_created | readonly | boolean | undefined | Whether the session has been created or joined by the current client. | SessionBase.has_been_created |
client_id | public | UUID | null | null | The id of the client that is currently connected to the session. | SessionBase.client_id |
token | readonly | string | undefined | The authentication token. | SessionBase.token |
is_guest | readonly | boolean | false | Whether 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
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
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type | Description |
|---|---|---|
this | T | - |
params | { scene_id: UUID; token: string; is_transient?: boolean; options?: Record<string, boolean>; } | - |
params.scene_id | UUID | The unique identifier of the scene the session will launch. |
params.token | string | The authentication token. This token must have at least read access to the scene. |
params.is_transient? | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
this | T | - |
params | { session_info: SessionInfo; token: string; } | - |
params.session_info | SessionInfo | The information about the session. |
params.token | string | The authentication token. |
Returns
The session instance.
| Name | Type | Default value | Description |
|---|---|---|---|
info | SessionInfo | - | The information about the session. |
has_been_created | boolean | - | Whether the session has been created or joined by the current client. |
client_id | UUID | null | null | The id of the client that is currently connected to the session. |
token | string | - | The authentication token. |
is_guest | boolean | false | Whether the authentication token is a guest token. |
get scene_id | UUID | - | The unique identifier of the scene the session is running. |
get session_id | UUID | - | The unique identifier of the session. |
get client_ids | UUID[] | - | The unique identifiers of all clients connected to the session. |
get clients | ClientType[] | - | All the clients connected to the session. |
get other_clients | ClientType[] | - | All the clients connected to the session except the current client. |
get current_client | ClientType | 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
| Parameter | Type | Description |
|---|---|---|
params | { scene_id: UUID; token: string; } | - |
params.scene_id | UUID | The unique identifier of the scene the sessions must be running. |
params.token | string | The 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
| Parameter | Type | Description |
|---|---|---|
this | T | - |
params | { scene_id: UUID; token: string; session_selector: (__namedParameters: { sessions: SessionInfo[]; }) => SessionInfo | null; } | - |
params.scene_id | UUID | The unique identifier of the scene the session must be running. |
params.token | string | The authentication token. This token must have at least read access to the scene. |
params.session_selector | (__namedParameters: { sessions: SessionInfo[]; }) => SessionInfo | null | A 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
| Parameter | Type | Description |
|---|---|---|
this | T | - |
params | { session_id: UUID; token: string; } | - |
params.session_id | UUID | The unique identifier of the session to find. |
params.token | string | The 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
| Parameter | Type | Description |
|---|---|---|
this | T | - |
params | { guest_token: string; } | - |
params.guest_token | string | The 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
| Parameter | Type | Description |
|---|---|---|
params | { client_id: UUID; } | - |
params.client_id | UUID | The 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
| Parameter | Type | Description |
|---|---|---|
params | { client: UUID | Client; } | - |
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.
Inherited from
SessionBase.evictClient;