class DeviceSession
DeviceSession
(
deviceSelector
)
|
Creates a new DeviceSession with the specified device selector.
Signature
constructor(deviceSelector: DeviceSelector) Parameters Returns DeviceSession |
state
: StateFlow<DeviceSessionState>
[Get] |
A StateFlow that provides the current state of this device session.
The state indicates whether the session is currently connected to a device ( STARTED) or not connected (STOPPED). The state changes automatically based on device availability as determined by the provided DeviceSelector.
Signature
val state: StateFlow<DeviceSessionState> |
start
()
|
Starts monitoring for devices and establishes sessions when matching devices become available.
This method begins monitoring the device availability through the configured DeviceSelector. When a device matching the selector criteria becomes available, the session automatically connects to it and transitions to the STARTED state. If the device becomes unavailable, the session automatically disconnects and transitions to the STOPPED state.
Signature
fun start() |
stop
()
|
Stops the device session and disconnects from any currently connected device.
This method stops monitoring for device availability and immediately disconnects from any currently connected device. The session state transitions to STOPPED. After calling this method, no further automatic connections will be established until start() is called again.
Signature
fun stop() |