Broadcast() приватный Метод

private Broadcast ( TorrentManager manager ) : void
manager TorrentManager
Результат void
Пример #1
0
        /// <summary>
        /// Starts the TorrentManager
        /// </summary>
        public void Start()
        {
            ClientEngine.MainLoop.QueueWait((MainLoopTask) delegate {
                CheckRegisteredAndDisposed();

                this._engine.Start();
                // If the torrent was "paused", then just update the state to Downloading and forcefully
                // make sure the peers begin sending/receiving again
                if (this.State == TorrentState.Paused)
                {
                    Mode = new DownloadMode(this);
                    return;
                }

                if (!HasMetadata)
                {
                    Mode = new MetadataMode(this, _torrentSave);
#if !DISABLE_DHT
                    StartDHT();
#endif
                    return;
                }

                VerifyHashState();
                // If the torrent has not been hashed, we start the hashing process then we wait for it to finish
                // before attempting to start again
                if (!_hashChecked)
                {
                    if (State != TorrentState.Hashing)
                    {
                        HashCheck(true);
                    }
                    return;
                }

                if (State == TorrentState.Seeding || State == TorrentState.Downloading)
                {
                    return;
                }

                if (TrackerManager.CurrentTracker != null)
                {
                    if (this._trackerManager.CurrentTracker.CanScrape)
                    {
                        this.TrackerManager.Scrape();
                    }
                    this._trackerManager.Announce(TorrentEvent.Started); // Tell server we're starting
                }

                if (this.Complete && this._settings.InitialSeedingEnabled && ClientEngine.SupportsInitialSeed)
                {
                    Mode = new InitialSeedingMode(this);
                }
                else
                {
                    Mode = new DownloadMode(this);
                }
                _engine.Broadcast(this);

#if !DISABLE_DHT
                StartDHT();
#endif
                this._startTime = DateTime.Now;
                this._pieceManager.Reset();

                ClientEngine.MainLoop.QueueTimeout(TimeSpan.FromSeconds(2), delegate {
                    if (State != TorrentState.Downloading && State != TorrentState.Seeding)
                    {
                        return(false);
                    }
                    _pieceManager.Picker.CancelTimedOutRequests();
                    return(true);
                });
            });
        }