RelayManager<T> class

relay manager, responsible for lifecycle of relays, sending messages,
and help with tracking of requests

Constructors

RelayManager({required GlobalState globalState, required NostrTransportFactory nostrTransportFactory, EngineAdditionalDataFactory? engineAdditionalDataFactory, List<String>? bootstrapRelays, dynamic allowReconnect = true})
Creates a new relay manager.

Properties

allowReconnectRelays bool
gets allowed to reconnectRelays
getter/setter pair
connectedRelays List<RelayConnectivity>
Returns a list of fully connected relays, excluding connecting ones. DO NOT USE THIS FOR CHECKING A SINGLE RELAY, use isRelayConnected INSTEAD
no setter
engineAdditionalDataFactory EngineAdditionalDataFactory?
factory for creating additional data for the engine
final
globalState GlobalState
global state obj
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
nostrTransportFactory NostrTransportFactory
nostr transport factory, to create new transports (usually websocket)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
seedRelaysConnected Future<void>
completes when all seed relays are connected
no setter

Methods

closeAllTransports() Future<void>
Closes all transports
closeTransport(dynamic url) Future<void>
Closes this url transport and removes
connectRelay({required String dirtyUrl, required ConnectionSource connectionSource, int connectTimeout = DEFAULT_WEB_SOCKET_CONNECT_TIMEOUT}) Future<Tuple<bool, String>>
Connects to a relay to the relay pool. Returns a tuple with the first element being a boolean indicating success \ and the second element being a string with the error message if any.
doesRelaySupportNip(String url, int nip) bool
does relay support given nip
getRelayConnectivity(String url) RelayConnectivity?
return RelayConnectivity by url
getRelayInfo(String url) Future<RelayInfo?>
fetches relay info todo: refactor to use http injector and decouple data from fetching
isRelayConnected(String url) bool
checks if a relay is connected, avoid using this
isRelayConnecting(String url) bool
checks if a relay is connecting
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reconnectRelay(String url, {required ConnectionSource connectionSource, bool force = false}) Future<bool>
Reconnects to a relay, if the relay is not connected or the connection is closed.
reconnectRelays(Iterable<String> urls) Future<void>
Reconnects all given relays
registerRelayBroadcast({required String relayUrl, required Nip01Event eventToPublish}) → void
use this to register your broadcast against a relay,
this is needed so the response from a relay can be tracked back
registerRelayRequest({required String reqId, required String relayUrl, required List<Filter> filters}) → void
use this to register your request against a relay,
this is needed so the response from a relay can be tracked back
removeInFlightRequestById(String id) Future<void>
removes a request from the inFlightRequests
and closes the network controller
send(RelayConnectivity relayConnectivity, ClientMsg msg) → void
sends a ClientMsg to relay transport sink, throw an error if relay not connected
sendCloseToRelay(String url, String id) → void
sends a close message to a relay
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited