Appearance
Quick Start
This quick start guide describes the basic flow for measuring vital signs using the BiosenseSignal SDK.
Creating a Measurement Session
A session is an interface for performing vital sign measurements.
- Only a single session can be created at any given time. Terminate the previous session before creating a new session.
- A session is intended for a single user. When measuring the vital signs of another user, a new session must be created. See User Information.
The following code can be used to create a session with the relevant parameters:
TypeScript
import healthMonitorManager, {
FaceSessionOptions
} from '@biosensesignal/web-sdk';
await healthMonitorManager.initialize({
licenseKey,
});
const options: FaceSessionOptions = {
input: video.current,
cameraDeviceId: cameraId,
processingTime,
onVitalSign,
onFinalResults,
onError,
onWarning,
onStateChange,
onImageData,
};
const faceSession = await healthMonitorManager.createFaceSession(options);Waiting for the Session to Transition into ACTIVE State
The application can receive session state updates by using the OnStateChange callback interface:
TypeScript
import {
SessionState,
} from '@biosensesignal/web-sdk';
const onStateChange = useCallback((state: SessionState) => {
if (state == SessionState.ACTIVE) {
console.log("Session is ready to start measuring");
}
}, []);Note
For more information on session states and state transitions, see Session State section.
Starting a Measurement
A measurement can be started by calling the start() method:
TypeScript
session.start();Receiving Results During a Measurement
The application can receive instantaneous vital signs values by using OnVitalSign callback interface:
TypeScript
import {
VitalSigns,
} from '@biosensesignal/web-sdk';
const onVitalSign = useCallback((vitalSign: VitalSigns) => {
// Handle vital sign result
}, []);During the measurement, the instantaneous vital sign values are available only for specific vital signs, while the results of all vital signs are received once the measurement has been completed.
Note
For more information on receiving and handling vital sign information, see Vital Signs.
Stopping a Measurement
The measurement is stopped either after the measurement duration (provided in the start function) has ended, or when the stop method is called.
TypeScript
session.stop();Note
Calling the stop method initiates the calculation of the final results. See Vital Signs
Important
When the measurement stops, the session will transition to the STOPPING state.
The STOPPING state reflects that the session has initiated a stopping process that ends when the session state transitions to ACTIVE. At this point, a new measurement can be started.
Receiving Final Results
The application can receive final vital sign results and vital sign confidence levels by implementing OnFinalResults callsback interface:
TypeScript
import {
VitalSignsResults,
} from '@biosensesignal/web-sdk';
const onFinalResults = useCallback((vitalSignsResults: VitalSignsResults) => {
// Handle the final results of the measurements
}, []);The final results are computed when the session is in STOPPING state. For more information about receiving and handling the final results, see Vital Signs.
Terminating a Session
It is recommended to terminate the session whenever the measuring screen is not visible. The terminate() method provides a safe and structured way to shut down an active session. It ensures that all allocated resources are released properly while allowing execution to continue immediately.
Description
Terminates the active session and releases resources. This function initiates the termination process but does not block execution while waiting for it to complete.
Usage
TypeScript
session.terminate();
console.log("Session termination initiated.");Behavior
- If the session is already terminated, the function does nothing.
- If the session is active, it starts the termination process asynchronously.
- Non-blocking behavior: The function returns immediately, even if cleanup is still in progress.
Expected Developer Behavior
✅ Call terminate() when the session is no longer needed.
✅ Do not assume immediate termination; if logic depends on session termination, implement necessary wait logic before proceeding.
✅ Handle any warnings or logs to monitor the termination process.
❌ Do not attempt to restart a terminated session. A new session must be created instead.
Example Usage
TypeScript
session.terminate();
console.log("Session termination initiated.");Ensuring Completion Before Proceeding If subsequent actions depend on session termination, listen to the OnStateChange callback and make sure the session is terminated before proceeding:
TypeScript
import {
SessionState,
} from '@biosensesignal/web-sdk';
const onStateChange = useCallback((state: SessionState) => {
switch (state) {
case SessionState.TERMINATED:
console.log("Session is terminated");
break;
}
}, []);Session Lifecycle: Termination Flow
- Developer calls
terminate()→ Session enters the termination phase. - Internal cleanup begins (asynchronously) → Resources like the camera and processing units are released.
- Session state updates to
TERMINATEDonce the cleanup is complete. - Further API calls dependent on an active session will fail.
Frequently Asked Questions
❓ How can I know when termination is complete?
Since terminate() is non-blocking, you should not assume immediate completion. Instead: Monitor session state reaches the SessionState.TERMINATED state. Listen to system logs for confirmation.
❓ What happens if I call terminate() twice?
Calling terminate() on an already terminated session has no effect.
❓ Will terminate() throw errors?
No, terminate() handles errors internally. If error handling is required, monitor session state.
Conclusion
- Use
terminate()to properly close a session. - Expect non-blocking behavior – termination runs in the background.
- Check session state before and after termination if required.