NostrRelays class
This class is responsible for all the relays related operations.
- Implemented types
Constructors
Properties
-
eventsRegistry
→ Map<
NostrEventKey, ReceivedNostrEvent> -
Represents a registry of all events you received from all relays so far.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
relaysWebSocketsRegistry
→ Map<
String, WebSocket> -
Represents a registry of all relays that you did registered with the init method.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
closeEventsSubscription(
String subscriptionId) → void -
{@template close_events_subscription}
This method will close the subscription of the
subscriptionId
that you passed to it.override -
init(
{required List< String> relaysUrl, void onRelayListening(String relayUrl, dynamic receivedData, WebSocket? relayWebSocket)?, void onRelayConnectionError(String relayUrl, Object? error, WebSocket? relayWebSocket)?, void onRelayConnectionDone(String relayUrl, WebSocket? relayWebSocket)?, bool lazyListeningToRelays = false, bool retryOnError = false, bool retryOnClose = false, bool ensureToClearRegistriesBeforeStarting = true, bool ignoreConnectionException = true, bool shouldReconnectToRelayOnNotice = false, Duration connectionTimeout = const Duration(seconds: 5)}) → Future<void> -
This method is responsible for initializing the connection to all relays.
It takes a List<String> of relays urls, then it connects to each relay and registers it for future use, if
relayUrl
is empty, it will throw an AssertionError since it doesn't make sense to connect to an empty list of relays.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
relayInformationsDocumentNip11(
{required String relayUrl}) → Future< RelayInformations> -
Ths method will get you RelayInformations that contains the given
relayUrl
using the NIP11 implementation.override -
sendEventToRelays(
SentNostrEvent event, {void onOk(NostrEventOkCommand ok)?}) → void -
This method is responsible for sending an event to all relays that you did registered with the init method.
override
-
startEventsSubscription(
{required NostrRequest request, void onEose(NostrRequestEoseCommand ease)?}) → NostrEventsStream -
This method will send a
request
to all relays that you did registered with the init method, and gets your a Stream of NostrEvents that will be filtered by therequest
'ssubscriptionId
automatically.override -
startListeningToRelay(
{required String relay, required void onRelayListening(String relayUrl, dynamic receivedData, WebSocket? relayWebSocket)?, required void onRelayConnectionError(String relayUrl, Object? error, WebSocket? relayWebSocket)?, required void onRelayConnectionDone(String relayUrl, WebSocket? relayWebSocket)?, required bool retryOnError, required bool retryOnClose, required bool shouldReconnectToRelayOnNotice, required Duration connectionTimeout, required bool ignoreConnectionException, required bool lazyListeningToRelays, void onNoticeMessageFromRelay(String relay, WebSocket? relayWebSocket, NostrNotice notice)?}) → void -
This method will start listening to all relays that you did registered with the init method.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited