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 void Unregister(PeerListener listener) { listener.ConnectionReceived -= ConnectionReceived; }
public ClientEngine(EngineSettings settings, PeerListener listener) : this(settings, listener, new DiskWriter()) { }
public void Register(PeerListener listener) { listener.ConnectionReceived += ConnectionReceived; }