NostrRelays class

This class is responsible for all the relays related operations.

Implemented types

Constructors

NostrRelays()

Properties

eventsRegistry Map<NostrEventKey, NostrEvent>
Represents a registry of all events you received from all relays so far.
no setteroverride
eventsStream Stream<NostrEvent>
This is the stream which will have all events from all relays, all your sent requests will be included in this stream, and so in order to filter them, you will need to use the Stream.where method.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
noticesStream Stream<NostrNotice>
This is the stream which will have all notices from all relays, all of them will be included in this stream, and so in order to filter them, you will need to use the Stream.where method.
no setteroverride
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(NostrEvent 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}) 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 the request's subscriptionId 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