interface PeerListener
Modifier and Type | Method and Description |
---|---|
void |
connected(Peer peer)
Called when the connection to the peer has started and the
handshake was successfull.
|
void |
disconnected(Peer peer)
Called when the connection to the peer was terminated or the
connection handshake failed.
|
void |
downloaded(Peer peer,
int size)
Called when a (partial) piece has been downloaded from the peer.
|
PartialPiece |
getPartialPiece(Peer peer,
BitField havePieces)
Called when a peer has connected and there may be a partially
downloaded piece that the coordinatorator can give the peer task
|
I2PSnarkUtil |
getUtil()
Convenience
|
boolean |
gotBitField(Peer peer,
BitField bitfield)
Called when a bitmap message is received.
|
void |
gotChoke(Peer peer,
boolean choke)
Called when a choke message is received.
|
void |
gotExtension(Peer peer,
int id,
byte[] bs)
Called when an extension message is received.
|
boolean |
gotHave(Peer peer,
int piece)
Called when a have piece message is received.
|
void |
gotInterest(Peer peer,
boolean interest)
Called when an interested message is received.
|
void |
gotPeers(Peer peer,
List<PeerID> pIDList)
Called when peers are received via PEX
|
boolean |
gotPiece(Peer peer,
PartialPiece piece)
Called when a piece is received from the peer.
|
void |
gotPort(Peer peer,
int port,
int rport)
Called when a DHT port message is received.
|
ByteArray |
gotRequest(Peer peer,
int piece,
int off,
int len)
Called when the peer wants (part of) a piece from us.
|
boolean |
needPiece(Peer peer,
BitField bitfield)
Called when we are downloading from the peer and may need to ask for
a new piece.
|
void |
savePartialPieces(Peer peer,
List<Request> pcs)
Called when the peer has disconnected and the peer task may have a partially
downloaded piece that the PeerCoordinator can save
|
void |
uploaded(Peer peer,
int size)
Called when a (partial) piece has been uploaded to the peer.
|
int |
wantPiece(Peer peer,
BitField bitfield)
Called when we are downloading from the peer and need to ask for
a new piece.
|
void connected(Peer peer)
peer
- the Peer that just got connected.void disconnected(Peer peer)
peer
- the Peer that just got disconnected.void gotChoke(Peer peer, boolean choke)
peer
- the Peer that got the message.choke
- true when the peer got a choke message, false when
the peer got an unchoke message.void gotInterest(Peer peer, boolean interest)
peer
- the Peer that got the message.interest
- true when the peer got a interested message, false when
the peer got an uninterested message.boolean gotHave(Peer peer, int piece)
peer
- the Peer that got the message.piece
- the piece number that the per just got.boolean gotBitField(Peer peer, BitField bitfield)
peer
- the Peer that got the message.bitfield
- a BitField containing the pieces that the other
side has.boolean gotPiece(Peer peer, PartialPiece piece)
peer
- the Peer that got the piece.piece
- the piece received.ByteArray gotRequest(Peer peer, int piece, int off, int len)
peer.choke(false)
was called).peer
- the Peer that wants the piece.piece
- the piece number requested.off
- byte offset into the piece.len
- length of the chunk requested.void downloaded(Peer peer, int size)
peer
- the Peer from which size bytes where downloaded.size
- the number of bytes that where downloaded.void uploaded(Peer peer, int size)
peer
- the Peer to which size bytes where uploaded.size
- the number of bytes that where uploaded.int wantPiece(Peer peer, BitField bitfield)
gotPiece()
is called.peer
- the Peer that will be asked to provide the piece.bitfield
- a BitField containing the pieces that the other
side has.boolean needPiece(Peer peer, BitField bitfield)
peer
- the Peer that will be asked to provide the piece.bitfield
- a BitField containing the pieces that the other
side has.void savePartialPieces(Peer peer, List<Request> pcs)
peer
- the peerPartialPiece getPartialPiece(Peer peer, BitField havePieces)
havePieces
- the have-pieces bitmask for the peervoid gotExtension(Peer peer, int id, byte[] bs)
peer
- the Peer that got the message.id
- the message IDbs
- the message payloadvoid gotPort(Peer peer, int port, int rport)
peer
- the Peer that got the message.port
- the query portrport
- the response portvoid gotPeers(Peer peer, List<PeerID> pIDList)
peer
- the Peer that got the message.pIDList
- the peer IDs (dest hashes)I2PSnarkUtil getUtil()