Example #1
0
        private void OnAnnounceComplete(object sender, AnnounceResponseEventArgs e)
        {
            _updateSucceeded = e.Successful;
            if (_manager.Engine == null)
            {
                e.Id.WaitHandle.Set();
                return;
            }

            if (e.Successful)
            {
                _manager.Peers.BusyPeers.Clear();
                var count = _manager.AddPeersCore(e.Peers);
                _manager.RaisePeersFound(new TrackerPeersAdded(_manager, count, e.Peers.Count, e.Tracker));

                var tier = _trackerTiers.Find(t => t.Trackers.Contains(e.Tracker));
                if (tier != null)
                {
                    Toolbox.Switch(tier.Trackers, 0, tier.IndexOf(e.Tracker));
                    Toolbox.Switch(_trackerTiers, 0, _trackerTiers.IndexOf(tier));
                }
                e.Id.WaitHandle.Set();
            }
            else
            {
                TrackerTier tier;
                Tracker     tracker;

                if (!e.Id.TrySubsequent || !GetNextTracker(e.Tracker, out tier, out tracker))
                {
                    e.Id.WaitHandle.Set();
                }
                else
                {
                    Announce(tracker, e.Id.TorrentEvent, true, e.Id.WaitHandle);
                }
            }
        }