disconnect method

Future<void> disconnect()

Closes the websocket connection without disposing the client. Needs manual reconnect() call.

Implementation

Future<void> disconnect() async {
  _reconnectTimer?.cancel();
  _reconnectTimer = null;
  _reconnectInProgress = false;
  _reconnectAttemptCount = 0;
  _shouldResubscribeAfterReconnect = true;
  _failPendingEmits(
    StateError('MongoRealtime was disconnected before emit completed.'),
  );
  await _webSocketService.disconnect();
  _onDisconnected?.call(null);
}