Skip to main content

ActivityWatcher

Defined in: node_modules/@3dverse/livelink.core/dist/sources/ActivityWatcher.d.ts:31

Watch activity on the gateway.

Activity is defined as any message sent to the gateway that is not a heartbeat.

Internally the activity watcher uses two timeouts:

  • Inactivity warning: the time in seconds after which the InactivityWarningEvent event is dispatched.
  • Inactivity timeout: the time in seconds after which the DisconnectedEvent event is dispatched.

Whenever an internal activity is detected like a message being sent to the gateway, the activity watcher is reset and a ActivityDetectedEvent event is dispatched.

The application should listen to these events and act accordingly.

Usually, when the InactivityWarningEvent event is dispatched, the application should display a warning to the user. It is up to the application to decide what can be qualified as activity. For example, the application could consider the user moving the mouse as activity. In this case, the application would listen to the "mousemove" event and reset the activity watcher whenever the mouse is moved calling the ActivityWatcher.reset method.

The application should also listen to the ActivityDetectedEvent event and update the UI accordingly.

Once the inactivity timeout is reached it automatically triggers the disconnection from the gateway, and a DisconnectedEvent is dispatched with inactivity as the reason. In this case, there is no way to recover the connection. The application should let the user know that the connection has been lost.

Constructors

new ActivityWatcher()

new ActivityWatcher(): ActivityWatcher

Returns

ActivityWatcher

Properties

PropertyTypeDescription
reset() => voidReset the timeouts.

Accessors

inactivity_warning

Get Signature

get inactivity_warning(): number

Defined in: node_modules/@3dverse/livelink.core/dist/sources/ActivityWatcher.d.ts:37

Inactivity warning in seconds. Amount of time in seconds after which the on-inactivity-warning event is dispatched.

Returns

number


inactivity_timeout

Get Signature

get inactivity_timeout(): number

Defined in: node_modules/@3dverse/livelink.core/dist/sources/ActivityWatcher.d.ts:42

Inactivity timeout in seconds. Amount of time in seconds after which the on-timeout event is dispatched.

Returns

number


is_running

Get Signature

get is_running(): boolean

Defined in: node_modules/@3dverse/livelink.core/dist/sources/ActivityWatcher.d.ts:46

True if the timeouts have been started.

Returns

boolean


has_timed_out

Get Signature

get has_timed_out(): boolean

Defined in: node_modules/@3dverse/livelink.core/dist/sources/ActivityWatcher.d.ts:50

True if activity watcher has timed out

Returns

boolean

Methods

setTimeouts()

setTimeouts(params: {
warn_after_seconds: number;
timeout_after_seconds: number;
}): void

Defined in: node_modules/@3dverse/livelink.core/dist/sources/ActivityWatcher.d.ts:61

Set the timeouts.

Setting these values will reset the activity watcher if it is running.

Parameters

ParameterTypeDescription
params{ warn_after_seconds: number; timeout_after_seconds: number; }
params.warn_after_secondsnumberAmount of time in seconds after which the on-warning event is dispatched. Must be less than timeout_after_seconds.
params.timeout_after_secondsnumberAmount of time in seconds after which the on-timeout event is dispatched.

Returns

void