disconnect method
Implementation
Future<void> disconnect() async {
await _subscription?.cancel();
_subscription = null;
try {
await _api.disconnect();
} catch (_) {
// Already gone; the UI state below is what matters.
}
connected = false;
_notify();
}