WebSocketTestDriverCommunicator constructor

WebSocketTestDriverCommunicator({
  1. required String appIdentifier,
  2. String? driverId,
  3. required String driverName,
  4. Logger? logger,
  5. Duration maxConnectionTime = const Duration(minutes: 30),
  6. Duration pingTime = const Duration(seconds: 30),
  7. required String secret,
  8. required String url,
})

The communicator that can be used by applications to drive test devices via the websocket server.

The appIdentifier must match either the application's build time package identifier, or more ideally, the value past into the application at startup via TestAppSettings.initialize.

The driverId is optional and will default to a random UUID if not set.

The driverName is intended to be a human readable display value to allow members of a team to see who is utilizing which devices.

The logger is an optional logger that an application may pass in to have the log events go via a custom logger rather than a class default one.

The maxConnectionTime describes the maxiumum amount of time the communicator may remain connected to the server before it should disconnect and reconnect. Many hosted websocket servers only allow a limited amount of time that a websocket can be open before requiring a reconnect. Use an arbitrarily large value to effectively mean "forever".

The pingTime describes how long to wait between pings to the server.

The secret is the driver secret or pre-shared-key that has been loaded on the server. This key will be used to generate and respond to HMAC based authentication challenges to authenticate with the server.

The url is the websocket based URL of the server.

Implementation

WebSocketTestDriverCommunicator({
  required this.appIdentifier,
  String? driverId,
  required this.driverName,
  Logger? logger,
  this.maxConnectionTime = const Duration(minutes: 30),
  this.pingTime = const Duration(seconds: 30),
  required String secret,
  required this.url,
})  : assert(secret.isNotEmpty == true),
      driverId = driverId ?? const Uuid().v4(),
      _logger = logger ?? Logger('WebSocketTestDriverCommunicator'),
      _secret = secret;