-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.go
More file actions
55 lines (44 loc) · 1.18 KB
/
events.go
File metadata and controls
55 lines (44 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package bittorrent
// XXX all events should contain a timestamp
import "time"
type Event interface {
isEvent()
}
func (EventPeerTraffic) isEvent() {}
func (EventPeerNoTraffic) isEvent() {}
func (EventPeerDisconnected) isEvent() {}
func (EventAnnounceFailed) isEvent() {}
func (EventPeerUnchoked) isEvent() {}
func (EventPeerChoked) isEvent() {}
func (EventPeerConnected) isEvent() {}
// EventPeerTraffic is emitted once a peer has traffic.
// It will not be sent again for the same peer until an EventPeerNoTraffic has been emitted.
type EventPeerTraffic struct {
Peer *Peer
}
// EventPeerNoTraffic is emitted once a peer no longer has any traffic.
type EventPeerNoTraffic struct {
Peer *Peer
}
// EventPeerConnected is emitted when a peer has connected and finished its half of the handshake.
type EventPeerConnected struct {
Peer *Peer
Torrent *Torrent
}
type EventPeerDisconnected struct {
When time.Time
Peer *Peer
Err error
}
type EventAnnounceFailed struct {
Announce Announce
}
type EventPeerUnchoked struct {
Peer *Peer
Torrent *Torrent
Reason string // XXX make this an enum
}
type EventPeerChoked struct {
Peer *Peer
Torrent *Torrent
}