pause method

Future<void> pause()

Pauses the client (typically when the mobile app enters background).

Disconnects the underlying WebSocket gracefully to conserve battery and radio resources without triggering reconnection loops.

Implementation

Future<void> pause() async {
  if (_isPaused || _disposed) return;
  _isPaused = true;
  _reconnectTimer?.cancel();
  _reconnectTimer = null;
  _reconnectInProgress = false;
  final future = _webSocketService.disconnect(manual: false);
  _pauseFuture = future;
  try {
    await future;
  } finally {
    if (identical(_pauseFuture, future)) {
      _pauseFuture = null;
    }
  }
}