protected virtual void RaiseAnnounceComplete(AnnounceResponseEventArgs e) { EventHandler <AnnounceResponseEventArgs> h = AnnounceComplete; if (h != null) { h(this, e); } }
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); } } }
public void AddPeer(Peer p) { TrackerConnectionID id = new TrackerConnectionID(this, false, TorrentEvent.None, null); AnnounceResponseEventArgs e = new AnnounceResponseEventArgs(this, null, true); e.Peers.Add(p); e.Successful = true; RaiseAnnounceComplete(e); }
public void AddPeer(Peer p) { TrackerConnectionID id = new TrackerConnectionID(this, false, TorrentEvent.None, new ManualResetEvent(false)); AnnounceResponseEventArgs e = new AnnounceResponseEventArgs(this, id, true); e.Peers.Add(p); RaiseAnnounceComplete(e); Assert.IsTrue(id.WaitHandle.WaitOne(1000, true), "#1 Tracker never raised the AnnounceComplete event"); }
protected virtual void RaiseAnnounceComplete(AnnounceResponseEventArgs e) { EventHandler<AnnounceResponseEventArgs> h = AnnounceComplete; if (h != null) h(this, e); }