java.lang.Object
org.klomp.snark.UDPTrackerClient.TrackerResponse
Enclosing class:
UDPTrackerClient

public static class UDPTrackerClient.TrackerResponseextends Object
Represents a response from a UDP tracker.
This class encapsulates the tracker's response including peer lists, interval information, and any error messages.
  • Field Details

    • interval

      private final int interval
      Seconds until the next announce, set by the tracker.
    • complete

      private final int complete
      Peers with the torrent complete.
    • incomplete

      private final int incomplete
      Peers still downloading.
    • error

      private final String error
      Error message from the tracker, or null.
    • peers

      private final Set<Hash> peers
      Peers returned by the reply.
  • Constructor Details

    • TrackerResponse

      public TrackerResponse(int interval, int seeds, int leeches, Set<Hash> peers)
      Builds a successful response from the tracker's swarm statistics.
      Parameters:
      interval - seconds the tracker asks us to wait before the next announce
      seeds - number of complete peers the tracker reports in the swarm
      leeches - number of incomplete peers the tracker reports in the swarm
      peers - the peer hashes returned by the tracker
    • TrackerResponse

      public TrackerResponse(String errorMsg)
      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

      public Set<Hash> getPeers()
      The peers.
      Returns:
      the peer hashes, as parsed from the tracker reply
    • 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

      public String 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