sub.mx raw
1 package relay
2
3 import "smesh.lol/web/common/nostr"
4
5 // Sub is an active subscription on a relay connection.
6 type Sub struct {
7 ID string
8 Filters []*nostr.Filter
9 OnEvent func(*nostr.Event)
10 OnEOSE func()
11 conn *Conn
12 gotEOSE bool
13 }
14
15 // GotEOSE returns whether EOSE has been received.
16 func (s *Sub) GotEOSE() bool {
17 return s.gotEOSE
18 }
19
20 // Close unsubscribes.
21 func (s *Sub) Close() {
22 if s.conn != nil {
23 s.conn.CloseSubscription(s.ID)
24 }
25 }
26