Readonly
relaysPublish an event to all relays in this set. Returns the number of relays that have received the event.
Optional
timeoutMs: numbertimeout in milliseconds for each publish operation and connection operation
A set where the event was successfully published to
PublishError if no relay was able to receive the event
const event = new NDKEvent(ndk, {kinds: [NDKKind.Message], "#d": ["123"]});
try {
const publishedToRelays = await relaySet.publish(event);
console.log(`published to ${publishedToRelays.size} relays`)
} catch (error) {
console.error("error publishing to relays", error);
if (error instanceof PublishError) {
for (const [relay, err] of error.errors) {
console.error(`error publishing to relay ${relay.url}`, err);
}
}
}
Static
fromCreates a relay set from a list of relay URLs.
If no connection to the relay is found in the pool it will temporarily connect to it.
list of relay URLs to include in this set
NDKRelaySet
Generated using TypeDoc
A relay set is a group of relays. This grouping can be short-living, for a single REQ or can be long-lasting, for example for the explicit relay list the user has specified.
Requests to relays should be sent through this interface.