getRelayWebSocket static method

WebSocket? getRelayWebSocket({
  1. required String relayUrl,
})

Returns the WebSocket registered with the given relayUrl.

Implementation

static WebSocket? getRelayWebSocket({
  required String relayUrl,
}) {
  final targetWebSocket = relaysWebSocketsRegistry[relayUrl];

  if (targetWebSocket != null) {
    final relay = targetWebSocket;

    return relay;
  } else {
    NostrClientUtils.log(
      "No relay is registered with the given url: $relayUrl, did you forget to register it?",
    );

    throw RelayNotFoundException(relayUrl);
  }
}