reconnectToRelays method

  1. @override
Future<void> reconnectToRelays({
  1. required void onRelayListening(
    1. String relayUrl,
    2. dynamic receivedData,
    3. WebSocketChannel? relayWebSocket
    )?,
  2. required void onRelayConnectionError(
    1. String relayUrl,
    2. Object? error,
    3. WebSocketChannel? relayWebSocket
    )?,
  3. required void onRelayConnectionDone(
    1. String relayUrl,
    2. WebSocketChannel? relayWebSocket
    )?,
  4. required bool retryOnError,
  5. required bool retryOnClose,
  6. required bool shouldReconnectToRelayOnNotice,
  7. required Duration connectionTimeout,
  8. required bool ignoreConnectionException,
  9. required bool lazyListeningToRelays,
  10. bool relayUnregistered = true,
})
override

Implementation

@override
Future<void> reconnectToRelays({
  required void Function(
    String relayUrl,
    dynamic receivedData,
    WebSocketChannel? relayWebSocket,
  )? onRelayListening,
  required void Function(
    String relayUrl,
    Object? error,
    WebSocketChannel? relayWebSocket,
  )? onRelayConnectionError,
  required void Function(String relayUrl, WebSocketChannel? relayWebSocket)?
      onRelayConnectionDone,
  required bool retryOnError,
  required bool retryOnClose,
  required bool shouldReconnectToRelayOnNotice,
  required Duration connectionTimeout,
  required bool ignoreConnectionException,
  required bool lazyListeningToRelays,
  bool relayUnregistered = true,
}) async {
  final completer = Completer();

  if (relaysList == null || relaysList!.isEmpty) {
    throw Exception(
      'you need to call the init method before calling this method.',
    );
  }

  for (final relay in relaysList!) {
    await _reconnectToRelay(
      relayUnregistered: relayUnregistered,
      relay: relay,
      onRelayListening: onRelayListening,
      onRelayConnectionError: onRelayConnectionError,
      onRelayConnectionDone: onRelayConnectionDone,
      retryOnError: retryOnError,
      retryOnClose: retryOnClose,
      shouldReconnectToRelayOnNotice: shouldReconnectToRelayOnNotice,
      connectionTimeout: connectionTimeout,
      ignoreConnectionException: ignoreConnectionException,
      lazyListeningToRelays: lazyListeningToRelays,
    );
  }

  completer.complete();

  return completer.future;
}