disconnectFromRelays method
Implementation
Future<bool> disconnectFromRelays({
int Function(String relayUrl)? closeCode,
String Function(String relayUrl)? closeReason,
void Function(
String relayUrl,
WebSocket relayWebSOcket,
dynamic webSocketDisconnectionMessage,
)? onRelayDisconnect,
}) async {
final webSockets = nostrRegistry.relaysWebSocketsRegistry;
for (var index = 0; index < webSockets.length; index++) {
final current = webSockets.entries.elementAt(index);
final relayUrl = current.key;
final relayWebSocket = current.value;
final returnedMessage = await relayWebSocket.close(
closeCode?.call(relayUrl),
closeReason?.call(relayUrl),
);
onRelayDisconnect?.call(relayUrl, relayWebSocket, returnedMessage);
}
nostrRegistry.clearWebSocketsRegistry();
relaysList = [];
return true;
}