public AddTorrentHandler(ISession session, IKeyValueStore keyValueStore, ITorrentMetadataRepository metadataRepository, ITorrentInfoSaver torrentInfoSaver) { if (session == null) { throw new ArgumentNullException("session"); } if (keyValueStore == null) { throw new ArgumentNullException("keyValueStore"); } if (metadataRepository == null) { throw new ArgumentNullException("metadataRepository"); } if (torrentInfoSaver == null) { throw new ArgumentNullException("torrentInfoSaver"); } _session = session; _keyValueStore = keyValueStore; _metadataRepository = metadataRepository; _torrentInfoSaver = torrentInfoSaver; }
public SessionHandler(ILogger<SessionHandler> logger, IEnvironment environment, IFileSystem fileSystem, IKeyValueStore keyValueStore, IMessageBus messageBus, ISession session, ITorrentInfoRepository torrentInfoRepository, ITorrentMetadataRepository metadataRepository) { if (logger == null) throw new ArgumentNullException("logger"); if (environment == null) throw new ArgumentNullException("environment"); if (fileSystem == null) throw new ArgumentNullException("fileSystem"); if (keyValueStore == null) throw new ArgumentNullException("keyValueStore"); if (messageBus == null) throw new ArgumentNullException("messageBus"); if (session == null) throw new ArgumentNullException("session"); if (torrentInfoRepository == null) throw new ArgumentNullException("torrentInfoRepository"); if (metadataRepository == null) throw new ArgumentNullException("metadataRepository"); _logger = logger; _environment = environment; _fileSystem = fileSystem; _keyValueStore = keyValueStore; _messageBus = messageBus; _session = session; _torrentInfoRepository = torrentInfoRepository; _metadataRepository = metadataRepository; _muted = new List<string>(); _alertsThread = new Thread(ReadAlerts); }
public SessionHandler(ILogger <SessionHandler> logger, IEnvironment environment, IFileSystem fileSystem, IKeyValueStore keyValueStore, IMessageBus messageBus, ISession session, ITorrentInfoRepository torrentInfoRepository, ITorrentMetadataRepository metadataRepository) { if (logger == null) { throw new ArgumentNullException("logger"); } if (environment == null) { throw new ArgumentNullException("environment"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } if (keyValueStore == null) { throw new ArgumentNullException("keyValueStore"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } if (session == null) { throw new ArgumentNullException("session"); } if (torrentInfoRepository == null) { throw new ArgumentNullException("torrentInfoRepository"); } if (metadataRepository == null) { throw new ArgumentNullException("metadataRepository"); } _logger = logger; _environment = environment; _fileSystem = fileSystem; _keyValueStore = keyValueStore; _messageBus = messageBus; _session = session; _torrentInfoRepository = torrentInfoRepository; _metadataRepository = metadataRepository; _muted = new List <string>(); _alertsThread = new Thread(ReadAlerts); }
internal static ITorrent CreateFromHandle(TorrentHandle handle, ITorrentMetadataRepository metadataRepository) { using (handle) using (var file = handle.TorrentFile) using (var status = handle.QueryStatus()) { var t = new Torrent { InfoHash = handle.InfoHash.ToHex(), Name = status.Name, SavePath = status.SavePath, Size = file == null ? -1 : file.TotalSize, Progress = status.Progress, DownloadSpeed = status.DownloadRate, UploadSpeed = status.UploadRate, TotalDownloadedBytes = status.TotalDownload, TotalUploadedBytes = status.TotalUpload, State = (Common.BitTorrent.TorrentState)(int) status.State, Paused = status.Paused, Files = new ITorrentFile[file == null ? 0 : file.NumFiles], Peers = handle.GetPeerInfo().Select(Peer.CreateFromPeerInfo).ToArray() }; t.Label = metadataRepository.GetLabel(t.InfoHash); // If no torrent file (ie. downloading metadata) if (file == null) { return(t); } var progresses = handle.GetFileProgresses(); var priorities = handle.GetFilePriorities(); for (var i = 0; i < file.NumFiles; i++) { var entry = file.FileAt(i); var torrentFile = TorrentFile.CreateFromEntry(entry, progresses[i], priorities[i]); t.Files[i] = torrentFile; } return(t); } }
internal static ITorrent CreateFromHandle(TorrentHandle handle, ITorrentMetadataRepository metadataRepository) { using (handle) using (var file = handle.TorrentFile) using (var status = handle.QueryStatus()) { var t = new Torrent { InfoHash = handle.InfoHash.ToHex(), Name = status.Name, SavePath = status.SavePath, Size = file == null ? -1 : file.TotalSize, Progress = status.Progress, DownloadSpeed = status.DownloadRate, UploadSpeed = status.UploadRate, TotalDownloadedBytes = status.TotalDownload, TotalUploadedBytes = status.TotalUpload, State = (Common.BitTorrent.TorrentState) (int) status.State, Paused = status.Paused, Files = new ITorrentFile[file == null ? 0 : file.NumFiles], Peers = handle.GetPeerInfo().Select(Peer.CreateFromPeerInfo).ToArray() }; t.Label = metadataRepository.GetLabel(t.InfoHash); // If no torrent file (ie. downloading metadata) if (file == null) return t; var progresses = handle.GetFileProgresses(); var priorities = handle.GetFilePriorities(); for (var i = 0; i < file.NumFiles; i++) { var entry = file.FileAt(i); var torrentFile = TorrentFile.CreateFromEntry(entry, progresses[i], priorities[i]); t.Files[i] = torrentFile; } return t; } }
public AddUrlHandler(ISession session, IKeyValueStore keyValueStore, ITorrentMetadataRepository metadataRepository) { if (session == null) { throw new ArgumentNullException("session"); } if (keyValueStore == null) { throw new ArgumentNullException("keyValueStore"); } if (metadataRepository == null) { throw new ArgumentNullException("metadataRepository"); } _session = session; _keyValueStore = keyValueStore; _metadataRepository = metadataRepository; }
public ChangeTorrentLabelHandler(ITorrentEngine torrentEngine, ITorrentMetadataRepository metadataRepository, IMessageBus messageBus) { if (torrentEngine == null) { throw new ArgumentNullException("torrentEngine"); } if (metadataRepository == null) { throw new ArgumentNullException("metadataRepository"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } _torrentEngine = torrentEngine; _metadataRepository = metadataRepository; _messageBus = messageBus; }