Class NDKRelay

The NDKRelay class represents a connection to a relay.

Emits

NDKRelay#connect

Emits

NDKRelay#ready

Emits

NDKRelay#disconnect

Emits

NDKRelay#notice

Emits

NDKRelay#event

Emits

NDKRelay#published when an event is published to the relay

Emits

NDKRelay#publish:failed when an event fails to publish to the relay

Emits

NDKRelay#eose

Emits

NDKRelay#auth when the relay requires authentication

Hierarchy

  • EventEmitter
    • NDKRelay

Constructors

Properties

authPolicy?: NDKAuthPolicy
authRequired: boolean = false
complaining: boolean = false
connectivity: NDKRelayConnectivity
debug: Debugger
scores: Map<NDKUser, number>
trusted: boolean = false

Whether this relay is trusted.

Trusted relay's events do not get their signature verified.

url: string

Accessors

Methods

  • Publishes an event to the relay with an optional timeout.

    If the relay is not connected, the event will be published when the relay connects, unless the timeout is reached before the relay connects.

    Parameters

    • event: NDKEvent

      The event to publish

    • timeoutMs: number = 2500

      The timeout for the publish operation in milliseconds

    Returns Promise<boolean>

    A promise that resolves when the event has been published or rejects if the operation times out

  • Called when this relay has responded with an event but wasn't the fastest one.

    Parameters

    • timeDiffInMs: number

      The time difference in ms between the fastest and this relay in milliseconds

    Returns void

Generated using TypeDoc