Ejemplo n.º 1
0
        private async Task OnAnnounceComplete(ITracker tracker, List <Peer> peers, bool trySubsequent, TorrentEvent clientEvent, bool successful)
        {
            this.updateSucceeded = successful;
            if (manager.Engine == null)
            {
                return;
            }

            if (successful)
            {
                manager.Peers.BusyPeers.Clear();
                int count = await manager.AddPeersAsync(peers);

                manager.RaisePeersFound(new TrackerPeersAdded(manager, count, peers.Count, tracker));

                TrackerTier tier = trackerTiers.Find(delegate(TrackerTier t) { return(t.Trackers.Contains(tracker)); });
                if (tier != null)
                {
                    Toolbox.Switch(tier.Trackers, 0, tier.IndexOf(tracker));
                    Toolbox.Switch(trackerTiers, 0, trackerTiers.IndexOf(tier));
                }
            }
            else
            {
                TrackerTier tier;
                if (!trySubsequent || !GetNextTracker(tracker, out tier, out tracker))
                {
                    return;
                }
                else
                {
                    await Announce(tracker, clientEvent, true);
                }
            }
        }