/// <summary> /// Creates a new TrackerConnection for the supplied torrent file /// </summary> /// <param name="requestFactory">The factory used to create tracker requests. Typically a <see cref="TorrentManager"/> instance.</param> /// <param name="announces">The list of tracker tiers</param> internal TrackerManager(ITrackerRequestFactory requestFactory, IEnumerable <RawTrackerTier> announces) { RequestFactory = requestFactory; // Check if this tracker supports scraping var trackerTiers = new List <TrackerTier> (); foreach (RawTrackerTier tier in announces) { trackerTiers.Add(new TrackerTier(tier)); } trackerTiers.RemoveAll(tier => tier.Trackers.Count == 0); Tiers = trackerTiers.AsReadOnly(); }
/// <summary> /// Creates a new TrackerConnection for the supplied torrent file /// </summary> /// <param name="requestFactory">The factory used to create tracker requests. Typically a <see cref="TorrentManager"/> instance.</param> /// <param name="announces">The list of tracker tiers</param> /// <param name="isPrivate">True if adding/removing tracker should be disallowed.</param> internal TrackerManager(ITrackerRequestFactory requestFactory, IEnumerable <IEnumerable <string> > announces, bool isPrivate) { AnnounceLimiter = new SemaphoreSlim(10); RequestFactory = requestFactory; Private = isPrivate; var trackerTiers = new List <TrackerTier> (); foreach (var announceTier in announces) { var tier = new TrackerTier(announceTier); if (tier.Trackers.Count > 0) { tier.AnnounceComplete += RaiseAnnounceComplete; tier.ScrapeComplete += RaiseScrapeComplete; trackerTiers.Add(tier); } } Tiers = trackerTiers.AsReadOnly(); }