9 type AnnounceRequest struct {
18 NumWant int32 // How many peer addresses are desired. -1 for default.
22 type AnnounceResponse struct {
23 Interval int32 // Minimum seconds the local peer should wait before next announce.
29 type AnnounceEvent int32
37 None AnnounceEvent = iota
38 Completed // The local peer just completed the torrent.
39 Started // The local peer has just resumed this torrent.
40 Stopped // The local peer is leaving the swarm.
43 type Client interface {
44 // Returns ErrNotConnected if Connect needs to be called.
45 Announce(*AnnounceRequest) (AnnounceResponse, error)
51 ErrNotConnected = errors.New("not connected")
52 ErrBadScheme = errors.New("unknown scheme")
54 schemes = make(map[string]func(*url.URL) Client)
57 func RegisterClientScheme(scheme string, newFunc func(*url.URL) Client) {
58 schemes[scheme] = newFunc
61 // Returns ErrBadScheme if the tracker scheme isn't recognised.
62 func New(rawurl string) (cl Client, err error) {
63 url_s, err := url.Parse(rawurl)
67 newFunc, ok := schemes[url_s.Scheme]