deactivate method

  1. @override
Future<void> deactivate()

Deactivates the communicator and disconnects from the back end.

Implementation

@override
Future<void> deactivate() async {
  if (!deactivated) {
    deactivated = true;
    _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!(this, false);
    }
  }
}