public BitTorrentDownloader(string peerId, IBencodeParser bencodeParser, IHttpClientHelper httpClientHelper, ITcpSocketHelper tcpSocketHelper, ITorrentFactory torrentFactory, ITrackerResponseFactory trackerResponseFactory, IPeerEventDataFactory peerEventDataFactory) { _peerId = peerId; _bencodeParser = bencodeParser; _httpClientHelper = httpClientHelper; _tcpSocketHelper = tcpSocketHelper; _torrentFactory = torrentFactory; _trackerResponseFactory = trackerResponseFactory; _peerEventDataFactory = peerEventDataFactory; }
public PeerConnector(IPeerEventDataFactory peerEventDataFactory, ITcpSocketHelper tcpSocketHelper, string peerId, TorrentInfoSingle torrentInfo) { if (torrentInfo.InfoHash.Length != Constants.InfoHashLength) { throw new ArgumentException($"Info hash must be {Constants.InfoHashLength} bytes"); } if (peerId.Length != Constants.PeerIdLength) { throw new ArgumentException($"Peer id must be {Constants.PeerIdLength} bytes"); } PeerEventDataFactory = peerEventDataFactory; TcpSocketHelper = tcpSocketHelper; TorrentInfo = torrentInfo; PeerId = peerId; }
public SocketPeer(IPeerEventDataFactory peerEventDataFactory, Peer peer, Socket socket, TorrentInfoSingle torrentInfo, string peerId) { if (torrentInfo.InfoHash.Length != Constants.InfoHashLength) { throw new ArgumentException($"Info hash must be {Constants.InfoHashLength} bytes"); } if (peerId.Length != Constants.PeerIdLength) { throw new ArgumentException($"Peer id must be {Constants.PeerIdLength} bytes"); } PeerEventDataFactory = peerEventDataFactory; Peer = peer; Socket = socket; PeerId = peerId; InfoHash = torrentInfo.InfoHash; PieceLength = torrentInfo.PieceLength; PieceAmount = torrentInfo.PieceHashes.Count; }