subscription

package
v1.2.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2024 License: GPL-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventMessage

type EventMessage struct {
	Event eventenvelope.T
	Relay string
}

type T

type T struct {
	Label   string
	Counter int

	Relay   relay.I
	Filters filters.T

	// for this to be treated as a COUNT and not a REQ this must be set
	CountResult chan int

	// the Events channel emits all EVENTs that come in a Subscription
	// will be closed when the subscription ends
	Events event.C

	// the EndOfStoredEvents channel gets closed when an EOSE comes for that
	// subscription
	EndOfStoredEvents chan struct{}

	// the ClosedReason channel emits the reason when a CLOSED message is
	// received
	ClosedReason chan string

	// Context will be .Done() when the subscription ends
	Context context.T

	Cancel context.F
	// contains filtered or unexported fields
}

func (*T) Close

func (sub *T) Close()

Close just sends a CLOSE message. You probably want Unsub() instead.

func (*T) DispatchClosed

func (sub *T) DispatchClosed(reason string)

func (*T) DispatchEose

func (sub *T) DispatchEose()

func (*T) DispatchEvent

func (sub *T) DispatchEvent(evt *event.T)

func (*T) Fire

func (sub *T) Fire() error

Fire sends the "REQ" command to the relay.

func (*T) GetID

func (sub *T) GetID() string

GetID return the Nostr subscription ID as given to the I it is a concatenation of the label and a serial number.

func (*T) Start

func (sub *T) Start()

func (*T) Sub

func (sub *T) Sub(_ context.T, f filters.T)

Sub sets sub.T and then calls sub.Fire(ctx). The subscription will be closed if the context expires.

func (*T) Unsub

func (sub *T) Unsub()

Unsub closes the subscription, sending "CLOSE" to relay as in NIP-01. Unsub() also closes the channel sub.Events and makes a new one.

type WithLabel

type WithLabel string

WithLabel puts a label on the subscription (it is prepended to the automatic id) that is sent to relays.

func (WithLabel) IsSubscriptionOption

func (_ WithLabel) IsSubscriptionOption()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL