コード例 #1
0
        public ClientEngine(EngineSettings settings, PeerListener listener, PieceWriter writer)
        {
            Check.Settings(settings);
            Check.Listener(listener);
            Check.Writer(writer);

            this.listener = listener;
            this.settings = settings;

            this.connectionManager = new ConnectionManager(this);
            RegisterDht(new NullDhtEngine());
            this.diskManager   = new DiskManager(this, writer);
            this.listenManager = new ListenManager(this);
            MainLoop.QueueTimeout(TimeSpan.FromMilliseconds(TickLength), delegate {
                if (IsRunning && !disposed)
                {
                    LogicTick();
                }
                return(!disposed);
            });
            this.torrents         = new List <TorrentManager>();
            this.torrentsReadonly = new ReadOnlyCollection <TorrentManager> (torrents);
            CreateRateLimiters();
            this.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));
            }
        }
コード例 #2
0
ファイル: ClientEngine.cs プロジェクト: ivaylo5ev/monotorrent
        public ClientEngine(EngineSettings settings, IPeerListener listener, PieceWriter writer)
        {
            Check.Settings(settings);
            Check.Listener(listener);
            Check.Writer(writer);

            this.Listener = listener;
            this.Settings = settings;

            this.ConnectionManager = new ConnectionManager(this);
            DhtEngine          = new NullDhtEngine();
            this.DiskManager   = new DiskManager(this, writer);
            this.listenManager = new ListenManager(this);
            MainLoop.QueueTimeout(TimeSpan.FromMilliseconds(TickLength), delegate {
                if (IsRunning && !Disposed)
                {
                    LogicTick();
                }
                return(!Disposed);
            });
            this.torrents         = new List <TorrentManager>();
            this.torrentsReadonly = new ReadOnlyCollection <TorrentManager> (torrents);
            downloadLimiter       = new RateLimiterGroup {
                new DiskWriterLimiter(DiskManager),
                new RateLimiter()
            };

            uploadLimiter = new RateLimiter();
            this.PeerId   = GeneratePeerId();

            localPeerListener            = new LocalPeerListener();
            localPeerListener.PeerFound += HandleLocalPeerFound;
            localPeerManager             = new LocalPeerManager();
            LocalPeerSearchEnabled       = SupportsLocalPeerDiscovery;
            listenManager.Register(listener);
        }
コード例 #3
0
ファイル: ClientEngine.cs プロジェクト: pilhlip/bitsharp-0.90
        public ClientEngine(EngineSettings settings, PeerListener listener, PieceWriter writer)
        {
            Check.Settings(settings);
            Check.Listener(listener);
            Check.Writer(writer);

            this.listener = listener;
            this.settings = settings;

            this.connectionManager = new ConnectionManager(this);
            RegisterDht (new NullDhtEngine());
            this.diskManager = new DiskManager(this, writer);
            this.listenManager = new ListenManager(this);
            MainLoop.QueueTimeout(TimeSpan.FromMilliseconds(TickLength), delegate {
                if (IsRunning && !disposed)
                    LogicTick();
                return !disposed;
            });
            this.torrents = new MonoTorrentCollection<TorrentManager>();
            CreateRateLimiters();
            this.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));
        }