Inheritance: IDisposable
Example #1
0
 private void PieceHashed(object sender, PieceHashedEventArgs e)
 {
     if (e.TorrentManager.State != TorrentState.Hashing)
     {
         DiskManager.QueueFlush(e.TorrentManager, e.PieceIndex);
     }
 }
Example #2
0
        public ClientEngine(EngineSettings settings, PeerListener listener, PieceWriter.PieceWriter writer)
        {
            Check.Settings(settings);
            Check.Listener(listener);
            Check.Writer(writer);

            Listener = listener;
            Settings = settings;

            ConnectionManager = new ConnectionManager(this);
            RegisterDht(new NullDhtEngine());
            DiskManager    = new DiskManager(this, writer);
            _listenManager = new ListenManager(this);
            MainLoop.QueueTimeout(TimeSpan.FromMilliseconds(TickLength), delegate
            {
                if (IsRunning && !Disposed)
                {
                    LogicTick();
                }
                return(!Disposed);
            });
            _torrents         = new List <TorrentManager>();
            _torrentsReadonly = new ReadOnlyCollection <TorrentManager>(_torrents);
            CreateRateLimiters();
            PeerId = GeneratePeerId();

            _localPeerListener     = new LocalPeerListener(this);
            _localPeerManager      = new LocalPeerManager();
            LocalPeerSearchEnabled = SupportsLocalPeerDiscovery;
            _listenManager.Register(listener);
            // This means we created the listener in the constructor
            if (listener.Endpoint.Port == 0)
            {
                listener.ChangeEndpoint(new IPEndPoint(IPAddress.Any, settings.ListenPort));
            }
        }
        public ClientEngine(EngineSettings settings, PeerListener listener, PieceWriter.PieceWriter writer)
        {
            Check.Settings(settings);
            Check.Listener(listener);
            Check.Writer(writer);

            Listener = listener;
            Settings = settings;

            ConnectionManager = new ConnectionManager(this);
            RegisterDht(new NullDhtEngine());
            DiskManager = new DiskManager(this, writer);
            _listenManager = new ListenManager(this);
            MainLoop.QueueTimeout(TimeSpan.FromMilliseconds(TickLength), delegate
            {
                if (IsRunning && !Disposed)
                    LogicTick();
                return !Disposed;
            });
            _torrents = new List<TorrentManager>();
            _torrentsReadonly = new ReadOnlyCollection<TorrentManager>(_torrents);
            CreateRateLimiters();
            PeerId = GeneratePeerId();

            _localPeerListener = new LocalPeerListener(this);
            _localPeerManager = new LocalPeerManager();
            LocalPeerSearchEnabled = SupportsLocalPeerDiscovery;
            _listenManager.Register(listener);
            // This means we created the listener in the constructor
            if (listener.Endpoint.Port == 0)
                listener.ChangeEndpoint(new IPEndPoint(IPAddress.Any, settings.ListenPort));
        }