WebSocketTestDeviceCommunicator constructor

WebSocketTestDeviceCommunicator({
  1. Duration maxConnectionTime = const Duration(minutes: 30),
  2. Duration pingTime = const Duration(seconds: 30),
  3. Duration reconnectDelay = const Duration(seconds: 1),
  4. required String secret,
  5. required TestControllerState testControllerState,
  6. required String url,
})

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

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 reconnectDelay is the amount of time the device will wait to reconnect to the server on a failed connec

The secret is the device 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 testControllerState is the state object describing the current testing status for the device. This can be retrieved via the application's test controller.

The url is the websocket based URL of the server.

Implementation

WebSocketTestDeviceCommunicator({
  this.maxConnectionTime = const Duration(minutes: 30),
  this.pingTime = const Duration(seconds: 30),
  this.reconnectDelay = const Duration(seconds: 1),
  required String secret,
  required TestControllerState testControllerState,
  required this.url,
})  : assert(secret.isNotEmpty == true),
      _secret = secret,
      _testControllerState = testControllerState;