4 "github.com/anacrolix/torrent/mse"
5 pp "github.com/anacrolix/torrent/peer_protocol"
8 // These are called synchronously, and do not pass ownership of arguments (do not expect to retain
9 // data after returning from the callback). The Client and other locks may still be held. nil
10 // functions are not called.
11 type Callbacks struct {
12 // Called after a peer connection completes the BitTorrent handshake. The Client lock is not
14 CompletedHandshake func(*PeerConn, InfoHash)
15 ReadMessage func(*PeerConn, *pp.Message)
16 // This can be folded into the general case below.
17 ReadExtendedHandshake func(*PeerConn, *pp.ExtendedHandshakeMessage)
18 PeerConnClosed func(*PeerConn)
19 // BEP 10 message. Not sure if I should call this Ltep universally. Each handler here is called
21 PeerConnReadExtensionMessage []func(PeerConnReadExtensionMessageEvent)
23 // Provides secret keys to be tried against incoming encrypted connections.
24 ReceiveEncryptedHandshakeSkeys mse.SecretKeyIter
26 ReceivedUsefulData []func(ReceivedUsefulDataEvent)
27 ReceivedRequested []func(PeerMessageEvent)
28 DeletedRequest []func(PeerRequestEvent)
29 SentRequest []func(PeerRequestEvent)
30 PeerClosed []func(*Peer)
32 // Called when a PeerConn has been added to a Torrent. It's finished all BitTorrent protocol
33 // handshakes, and is about to start sending and receiving BitTorrent messages. The extended
34 // handshake has not yet occurred. This is a good time to alter the supported extension
36 PeerConnAdded []func(*PeerConn)
39 type ReceivedUsefulDataEvent = PeerMessageEvent
41 type PeerMessageEvent struct {
46 type PeerRequestEvent struct {
51 type PeerConnReadExtensionMessageEvent struct {
53 // You can look up what protocol this corresponds to using the PeerConn.LocalLtepProtocolMap.
54 ExtensionNumber pp.ExtensionNumber