9 // Marshalled as binary by the UDP client, so be careful making changes.
10 type AnnounceRequest struct {
19 NumWant int32 // How many peer addresses are desired. -1 for default.
23 type AnnounceResponse struct {
24 Interval int32 // Minimum seconds the local peer should wait before next announce.
30 type AnnounceEvent int32
32 func (e AnnounceEvent) String() string {
33 // See BEP 3, "event".
34 return []string{"empty", "completed", "started", "stopped"}[e]
43 None AnnounceEvent = iota
44 Completed // The local peer just completed the torrent.
45 Started // The local peer has just resumed this torrent.
46 Stopped // The local peer is leaving the swarm.
50 ErrBadScheme = errors.New("unknown scheme")
53 func Announce(urlStr string, req *AnnounceRequest) (res AnnounceResponse, err error) {
54 return AnnounceHost(urlStr, req, "")
57 func AnnounceHost(urlStr string, req *AnnounceRequest, host string) (res AnnounceResponse, err error) {
58 _url, err := url.Parse(urlStr)
64 return announceHTTP(req, _url, host)
66 return announceUDP(req, _url)