示例#1
0
        public override void Execute()
        {
            GetPeersTask task = new GetPeersTask(engine, infoHash);

            task.Completed += GotPeers;
            task.Execute();
        }
示例#2
0
        private void GotPeers(object o, TaskCompleteEventArgs e)
        {
            e.Task.Completed -= GotPeers;
            GetPeersTask getpeers = (GetPeersTask)e.Task;

            foreach (Node n in getpeers.ClosestActiveNodes.Values)
            {
                if (n.Token == null)
                {
                    continue;
                }
                AnnouncePeer  query = new AnnouncePeer(engine.LocalId, infoHash, port, n.Token);
                SendQueryTask task  = new SendQueryTask(engine, query, n);
                task.Completed += SentAnnounce;
                task.Execute();
                activeAnnounces++;
            }

            if (activeAnnounces == 0)
            {
                RaiseComplete(new TaskCompleteEventArgs(this));
            }
        }
示例#3
0
 public override void Execute()
 {
     GetPeersTask task = new GetPeersTask(engine, infoHash);
     task.Completed += GotPeers;
     task.Execute();
 }