Single relay connection over WebSocket.
new
NRelay1(url: string,opts?: NRelay1Opts,)
private
closedByUser: boolean
private
ee: EventTarget
socket: Websocket
readonly
subscriptions: readonly NostrClientREQ[]
[Symbol.asyncDispose](): Promise<void>
protected
abortError(): DOMException
Close the relay connection and prevent it from reconnecting.
After this you should dispose of the NRelay1
instance and create a new one to connect again.
count(filters: NostrFilter[],opts?: { signal?: AbortSignal; },): Promise<{ count: number; approximate?: boolean; }>
private
createSocket(): Websocket
Create (and open) a WebSocket connection with automatic reconnect.
event(event: NostrEvent,opts?: { signal?: AbortSignal; },): Promise<void>
private
maybeStartIdleTimer(): void
Start the idle time if applicable.
private
on<K extends keyof EventMap>(key: K,signal?: AbortSignal,): AsyncIterable<EventMap[K]>
Get a stream of EE events.
private
once<K extends keyof EventMap>(key: K,signal?: AbortSignal,): Promise<EventMap[K]>
Wait for a single EE event.
query(filters: NostrFilter[],opts?: { signal?: AbortSignal; },): Promise<NostrEvent[]>
protected
receive(msg: NostrRelayMsg): void
Handle a NIP-01 relay message.
req(filters: NostrFilter[],opts?: { signal?: AbortSignal; },): AsyncGenerator<NostrRelayEVENT
| NostrRelayEOSE
| NostrRelayCLOSED>
protected
send(msg: NostrClientMsg): void
Send a NIP-01 client message to the relay.
private
stopIdleTimer(): void
Stop the idle timer.
private
wake(): void
Make a new WebSocket, but only if it was closed by an idle timeout.