reconnectRelay method
Implementation
Future<bool> reconnectRelay(String url, {bool force = false}) async {
Relay? relay = getRelay(url);
if (allowReconnectRelays) {
WebSocketChannel? webSocket = webSockets[Relay.clean(url)];
if (webSocket!=null) {
await webSocket.ready;
}
if (!isWebSocketOpen(url)) {
if (relay != null &&
!force &&
!relay.wasLastConnectTryLongerThanSeconds(
FAIL_RELAY_CONNECT_TRY_AFTER_SECONDS)) {
// don't try too often
return false;
}
if (!await connectRelay(url)) {
// could not connect
return false;
}
if (!isWebSocketOpen(url)) {
// web socket is not open
return false;
}
}
}
return true;
}