deactivate method

Future<void> deactivate()

Deactivates the communicator. Once deactivated

Implementation

Future<void> deactivate() async {
  if (!deactivated) {
    deactivated = true;

    try {
      _channel?.sink.add(GoodbyeCommand(complete: true).toString());
    } catch (_) {}

    _active = false;
    await _commandStreamController?.close();
    _commandStreamController = null;
    _commandQueue.clear();

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

    _commandTimer?.cancel();
    _commandTimer = null;

    _pingTimer?.cancel();
    _pingTimer = null;

    _reconnectTimer?.cancel();
    _reconnectTimer = null;

    _timer?.cancel();
    _timer = null;

    if (_onConnectionChanged != null) {
      await _onConnectionChanged!(false);
    }
  }
}