Search in sources :

Example 1 with TRTrackerAnnouncerResponse

use of com.biglybt.core.tracker.client.TRTrackerAnnouncerResponse in project BiglyBT by BiglySoftware.

the class CoreImpl method announceAll.

protected void announceAll(boolean force) {
    Logger.log(new LogEvent(LOGID, "Updating trackers"));
    GlobalManager gm = getGlobalManager();
    if (gm != null) {
        List downloads = gm.getDownloadManagers();
        long now = SystemTime.getCurrentTime();
        for (int i = 0; i < downloads.size(); i++) {
            DownloadManager dm = (DownloadManager) downloads.get(i);
            Long last_announce_l = (Long) dm.getUserData(DM_ANNOUNCE_KEY);
            long last_announce = last_announce_l == null ? create_time : last_announce_l.longValue();
            TRTrackerAnnouncer an = dm.getTrackerClient();
            if (an != null) {
                TRTrackerAnnouncerResponse last_announce_response = an.getLastResponse();
                if (now - last_announce > 15 * 60 * 1000 || last_announce_response == null || last_announce_response.getStatus() == TRTrackerAnnouncerResponse.ST_OFFLINE || force) {
                    dm.setUserData(DM_ANNOUNCE_KEY, new Long(now));
                    Logger.log(new LogEvent(LOGID, "    updating tracker for " + dm.getDisplayName()));
                    dm.requestTrackerAnnounce(true);
                }
            }
        }
    }
    PluginInterface dht_tracker_pi = getPluginManager().getPluginInterfaceByClass(DHTTrackerPlugin.class);
    if (dht_tracker_pi != null) {
        ((DHTTrackerPlugin) dht_tracker_pi.getPlugin()).announceAll();
    }
}
Also used : GlobalManager(com.biglybt.core.global.GlobalManager) LogEvent(com.biglybt.core.logging.LogEvent) TRTrackerAnnouncer(com.biglybt.core.tracker.client.TRTrackerAnnouncer) TRTrackerAnnouncerResponse(com.biglybt.core.tracker.client.TRTrackerAnnouncerResponse) AtomicLong(java.util.concurrent.atomic.AtomicLong) DHTTrackerPlugin(com.biglybt.plugin.tracker.dht.DHTTrackerPlugin) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

DownloadManager (com.biglybt.core.download.DownloadManager)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 LogEvent (com.biglybt.core.logging.LogEvent)1 TRTrackerAnnouncer (com.biglybt.core.tracker.client.TRTrackerAnnouncer)1 TRTrackerAnnouncerResponse (com.biglybt.core.tracker.client.TRTrackerAnnouncerResponse)1 DHTTrackerPlugin (com.biglybt.plugin.tracker.dht.DHTTrackerPlugin)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1