NostrRelays class
This class is responsible for all the relays related operations.
- Implemented types
Constructors
- NostrRelays({required NostrClientUtils utils})
- This class is responsible for all the relays related operations.
Properties
-
eventsRegistry
→ Map<
String, NostrEvent> -
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
- nostrRegistry ↔ NostrRegistry
-
This is responsible for registering and retrieving relays WebSockets that are connected to the app.
latefinal
-
relaysList
↔ List<
String> ? -
The list of relays urls that you did registered with the init method.
getter/setter pairoverride
-
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
- streamsController → NostrStreamsControllers
-
A service that manages the relays streams messages
final
- utils → NostrClientUtils
-
final
- webSocketsService → NostrWebSocketsService
-
A service that manages the relays web sockets connections
latefinal
Methods
-
closeEventsSubscription(
String subscriptionId) → void -
This method will close the subscription of the
subscriptionId
that you passed to it.override -
disconnectFromRelays(
{int closeCode(String relayUrl)?, String closeReason(String relayUrl)?, void onRelayDisconnect(String relayUrl, WebSocket relayWebSOcket, dynamic webSocketDisconnectionMessage)?}) → Future< bool> -
freeAllResources(
[bool throwOnFailure = false]) → Future< bool> -
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
-
reconnectToRelays(
{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, bool relayUnregistered = true}) → Future< void> -
override
-
relayInformationsDocumentNip11(
{required String relayUrl, bool throwExceptionIfExists = true}) → Future< RelayInformations?> -
Ths method will get you RelayInformations that contains the given
relayUrl
using the NIP11 implementation.override -
sendCountEventToRelays(
NostrCountEvent countEvent, {required void onCountResponse(NostrCountResponse countResponse)}) → void -
override
-
sendCountEventToRelaysAsync(
NostrCountEvent countEvent, {required Duration timeout}) → Future< NostrCountResponse> -
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
-
sendEventToRelaysAsync(
NostrEvent event, {required Duration timeout, void onOk(NostrEventOkCommand ok)?}) → Future< NostrEventOkCommand> -
This method is responsible for sending an event to all relays that you did registered with the init method, and gets you a Future of NostrEventOkCommand that will be triggered when the event is accepted by the relays.
override
-
startEventsSubscription(
{required NostrRequest request, void onEose(NostrRequestEoseCommand ease)?, bool useConsistentSubscriptionIdBasedOnRequestData = false}) → 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 -
startEventsSubscriptionAsync(
{required NostrRequest request, required Duration timeout, void onEose(NostrRequestEoseCommand ease)?, bool useConsistentSubscriptionIdBasedOnRequestData = false, bool shouldThrowErrorOnTimeoutWithoutEose = true}) → Future< List< NostrEvent> > -
Retuens a Future of List<NostrEvent> that will be triggered when the
onEose
callback is triggered of the subscription created by yourrequest
.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