示例#1
0
  public void tick() {

    peersManager.tick();
    choker.tick();

    Long waitTime = activeTracker.getInterval();
    if (incomingPeerListener.getReceivedConnection() == 0
        || peersManager.getActivePeersNumber() < 4) {
      waitTime = activeTracker.getMinInterval() != null ? activeTracker.getMinInterval() : 60;
    }

    long now = System.currentTimeMillis();
    if (now - activeTracker.getLastRequestTime() >= waitTime * 1000) {

      if (!stopped) {
        try {
          Object peers = trackerRequest(null).get(ByteBuffer.wrap("peers".getBytes()));
          if (peers != null) {
            addPeers(peers);
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
示例#2
0
 public void interrupted(Peer peer) {
   choker.interrupted(peer);
   pieceChooser.interrupted(peer);
 }
示例#3
0
 public void interested(Peer peer) {
   choker.interested(peer);
 }
示例#4
0
 public void notInterested(Peer peer) {
   choker.notInterested(peer);
 }
示例#5
0
 public void unchoke(Peer peer) {
   /* remove all the pending request */
   pieceChooser.interrupted(peer);
   choker.unchoke(peer);
   addRequests(peer);
 }