java.lang.Object
org.klomp.snark.UDPTrackerClient.TrackerResponse
- Enclosing class:
UDPTrackerClient
Represents a response from a UDP tracker.
This class encapsulates the tracker's response including peer lists, interval information, and any error messages.
This class encapsulates the tracker's response including peer lists, interval information, and any error messages.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intPeers with the torrent complete.private final StringError message from the tracker, or null.private final intPeers still downloading.private final intSeconds until the next announce, set by the tracker.Peers returned by the reply.Constructor Summary
ConstructorsConstructorDescriptionTrackerResponse(int interval, int seeds, int leeches, Set<Hash> peers) Builds a successful response from the tracker's swarm statistics.TrackerResponse(String errorMsg) Builds a response holding only the tracker's error, with no peers.Method Summary
All MethodsModifier and TypeMethodDescriptionThe failure reason.intIn seconds.intThe leech count.intPeer count from the tracker response.getPeers()The peers.intThe seed count.
Field Details
interval
private final int intervalSeconds until the next announce, set by the tracker.complete
private final int completePeers with the torrent complete.incomplete
private final int incompletePeers still downloading.error
Error message from the tracker, or null.peers
Constructor Details
TrackerResponse
Builds a successful response from the tracker's swarm statistics.- Parameters:
interval- seconds the tracker asks us to wait before the next announceseeds- number of complete peers the tracker reports in the swarmleeches- number of incomplete peers the tracker reports in the swarmpeers- the peer hashes returned by the tracker
TrackerResponse
Builds a response holding only the tracker's error, with no peers.- Parameters:
errorMsg- the tracker supplied reason the announce did not succeed
Method Details
getPeers
getPeerCount
public int getPeerCount()Peer count from the tracker response.- Returns:
- the peer count, derived from peers seen plus seed/leech counts
getSeedCount
public int getSeedCount()The seed count.- Returns:
- number of seeds from the tracker reply
getLeechCount
public int getLeechCount()The leech count.- Returns:
- number of leeches from the tracker reply
getFailureReason
The failure reason.- Returns:
- error message from the tracker, or null on success
getInterval
public int getInterval()In seconds.- Returns:
- seconds to wait before the next announce