pause method

void pause()

Pause the WebSocket connection by disabling auto-reconnect and closing the connection. Useful when the app is backgrounded to save resources.

Because we cannot predict the behavior of mobile operating systems handling websocket connections, it is better for the app developer to manually handle.

We provide standard methods to accomplish this.

Implementation

void pause() {
  autoReconnect = false;
  if (ws != null) {
    // Note we DO NOT set manuallyClosed to true here, unlike the
    // public close() method, because we plan to re-open the websocket,
    // and we do not want to cycle through the failover proxy servers.
    ws?.sink.close();
  }
}