reconnect method

Future<void> reconnect({
  1. String? url,
  2. Object? authData,
})

Reconnects the client to the server.

If an optional url is provided, the client reconnects to that URL; otherwise it reuses the current WebSocket URL. If authData is provided, it will be sent as request headers during the WebSocket handshake.

Implementation

Future<void> reconnect({String? url, Object? authData}) async {
  if (url != null) {
    final normalized = normalizeWebSocketUrl(url);
    _warn(normalized.warning);
    await _webSocketService.reconnect(
      url: normalized.url,
      authData: authData,
    );
  } else {
    await _webSocketService.reconnect(authData: authData);
  }

  await _queryManager.resubscribeActiveQueries();
}