コード例 #1
0
 public override void Handle(IDhtEngine engine, Node node)
 {
     base.Handle(engine, node);
     node.Token = Token;
     if (Nodes != null)
     {
         engine.Add(Node.FromCompactNode(Nodes));
     }
 }
コード例 #2
0
        public void Register(TorrentManager manager)
        {
            CheckDisposed();
            Check.Manager(manager);

            MainLoop.QueueWait(() =>
            {
                if (manager.Engine != null)
                {
                    throw new TorrentException("This manager has already been registered");
                }

                if (Contains(manager.Torrent))
                {
                    throw new TorrentException(
                        "A manager for this torrent has already been registered");
                }
                torrents.Add(manager);

                manager.PieceHashed += PieceHashed;
                manager.Engine       = this;
                manager.DownloadLimiter.Add(downloadLimiter);
                manager.UploadLimiter.Add(uploadLimiter);

                if (_fastResume != null)
                {
                    var fastResume = _fastResume
                                     .SingleOrDefault(fr => manager.InfoHash == fr.Infohash);
                    if (fastResume != null)
                    {
                        manager.LoadFastResume(fastResume);
                    }
                }

                if (dhtEngine != null && manager.Torrent != null && manager.Torrent.Nodes != null &&
                    dhtEngine.State != DhtState.Ready)
                {
                    try
                    {
                        dhtEngine.Add(manager.Torrent.Nodes);
                    }
                    catch
                    {
                        // FIXME: Should log this somewhere, though it's not critical
                    }
                }
            });

            if (TorrentRegistered != null)
            {
                TorrentRegistered(this, new TorrentEventArgs(manager));
            }
        }
コード例 #3
0
        public void Register(TorrentManager manager)
        {
            CheckDisposed();
            Check.Manager(manager);

            MainLoop.QueueWait((MainLoopTask) delegate {
                if (manager.Engine != null)
                {
                    throw new TorrentException("This manager has already been registered");
                }

                if (Contains(manager.Torrent))
                {
                    throw new TorrentException("A manager for this torrent has already been registered");
                }
                this.torrents.Add(manager);
                manager.PieceHashed += PieceHashed;
                manager.Engine       = this;
                manager.DownloadLimiter.Add(globalDownloadLimiter);
                manager.UploadLimiter.Add(globalUploadLimiter);
                lock (skeys)
                    skeys.Add(manager.InfoHash);
#if !DISABLE_DHT
                if (dhtEngine != null && manager.Torrent != null && manager.Torrent.Nodes != null && dhtEngine.State != DhtState.Ready)
                {
                    try
                    {
                        dhtEngine.Add(manager.Torrent.Nodes);
                    }
                    catch
                    {
                        // FIXME: Should log this somewhere, though it's not critical
                    }
                }
#endif
            });

            if (TorrentRegistered != null)
            {
                TorrentRegistered(this, new TorrentEventArgs(manager));
            }
        }
コード例 #4
0
 public override void Handle(IDhtEngine engine, Node node)
 {
     base.Handle(engine, node);
     engine.Add(Node.FromCompactNode(Nodes.TextBytes));
 }