Session constructor

Session({
  1. required Device device,
  2. required Driver driver,
  3. Logger? logger,
  4. required Future<void> onClose(),
})

Constructs the session with the device to be controlled, the driver performing the controlling actions, an optional logger that will be used for log events (instead of the unique class level loger if not set).

This also requires an onClose that will be called when the the session is fully closed by either the device or the driver.

Implementation

Session({
  required this.device,
  required this.driver,
  Logger? logger,
  required this.onClose,
}) : _logger = logger ??
          Logger(
            'Session - [${device.device.id}] [${driver.driverName}]',
          ) {
  device.driverName = driver.driverName;
  _logger.info('[SESSION]: opened');
}