activate method

  1. @override
Future<void> activate(
  1. Future<TestDeviceInfo> testDeviceInfoBuilder()
)

Activiates the communicator with callback that is expected to be able to provide the information about the test device when called.

Implementation

@override
Future<void> activate(
  Future<TestDeviceInfo> Function() testDeviceInfoBuilder,
) async {
  if (deactivated == true) {
    throw Exception('Communicator has already been deactivated');
  }

  _testDeviceInfoBuilder = testDeviceInfoBuilder;
  _active = true;

  _commandTimer?.cancel();
  _commandTimer = null;

  _pingTimer?.cancel();

  _reconnectTimer?.cancel();
  _reconnectTimer = null;

  await _channelSubscription?.cancel();
  _channelSubscription = null;

  await _commandStreamController?.close();
  _commandQueue.clear();
  _commandStreamController = StreamController<DeviceCommand>.broadcast();

  await _connect();
}