Added some NIP-42 functionality to the client (relay.go) (#38)
This commit is contained in:
@@ -24,8 +24,8 @@ type EventMessage struct {
|
||||
Relay string
|
||||
}
|
||||
|
||||
// Unsub closes the subscription, sending "CLOSE" to relay as in NIP-01
|
||||
// Unsub() also closes the channel sub.Events
|
||||
// Unsub closes the subscription, sending "CLOSE" to relay as in NIP-01.
|
||||
// Unsub() also closes the channel sub.Events.
|
||||
func (sub *Subscription) Unsub() {
|
||||
sub.mutex.Lock()
|
||||
defer sub.mutex.Unlock()
|
||||
@@ -37,14 +37,14 @@ func (sub *Subscription) Unsub() {
|
||||
sub.stopped = true
|
||||
}
|
||||
|
||||
// Sub sets sub.Filters and then calls sub.Fire(ctx)
|
||||
// Sub sets sub.Filters and then calls sub.Fire(ctx).
|
||||
func (sub *Subscription) Sub(ctx context.Context, filters Filters) {
|
||||
sub.Filters = filters
|
||||
sub.Fire(ctx)
|
||||
}
|
||||
|
||||
// Fire sends the "REQ" command to the relay
|
||||
// when ctx is cancelled, sub.Unsub() is called, closing the subscription
|
||||
// Fire sends the "REQ" command to the relay.
|
||||
// When ctx is cancelled, sub.Unsub() is called, closing the subscription.
|
||||
func (sub *Subscription) Fire(ctx context.Context) {
|
||||
message := []interface{}{"REQ", sub.id}
|
||||
for _, filter := range sub.Filters {
|
||||
|
||||
Reference in New Issue
Block a user