getRelayWebSocket method

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

Returns the WebSocket registered with the given relayUrl.

Implementation

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

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

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

    throw RelayNotFoundException(relayUrl);
  }
}