internal Piece(Torrent parent, int pieceNumber) { hash = new byte[20]; this.pieceNumber = pieceNumber; torrent = parent; Buffer.BlockCopy(((ValueString)torrent.Info["pieces"]).Bytes, pieceNumber * 20, hash, 0, 20); }
public void AddTorrent( Torrent torrent ) { mTorrents.Enqueue( torrent ); if ( !mInProgress ) { mInProgress = true; if ( mUseThread ) Threading.ThreadPool.QueueUserWorkItem( new Threading.WaitCallback( PrivateStart ) ); else PrivateStart( null ); } }
private void OnPeerConnected(BT.Torrent torrent, BT.Peer peer, bool connected) { if (connected) { this.peerListView.Invoke( new AddNewPeerDelegate( this.peerListView.Items.Add ), new object[] { new PeerListViewItem( peer ) } ); // this.peerListView.Items.Add(new PeerListViewItem(peer)); } else { LogDebugMessage( "Peer disconnected from mainform.cs: " + peer.ToString() ); this.peerListView.Invoke( new RemovePeerDelegate( RemovePeer ), peer ); } }
public TorrentListViewItem(BT.Torrent torrent) { this.torrent = torrent; this.Text = torrent.ToString(); this.SubItems.Add(torrent.Status.ToString()); this.SubItems.Add(""); this.SubItems.Add(""); torrent.StatusChanged += new BT.TorrentStatusChangedCallback(OnTorrentChangeStatus); torrent.PercentChanged += new BT.PercentChangedCallback(torrent_PercentChanged); torrent.TrackerError += new BT.TorrentTrackerErrorCallback(torrent_TrackerError); }
public TorrentListViewItem(BT.Torrent torrent) { this.torrent = torrent; this.Text = torrent.ToString(); this.SubItems.Add(torrent.Status.ToString()); this.SubItems.Add(""); this.SubItems.Add(""); torrent.StatusChanged += new BT.TorrentStatusChangedCallback(OnTorrentChangeStatus); torrent.PercentChanged += new BT.PercentChangedCallback( torrent_PercentChanged ); torrent.TrackerError += new BT.TorrentTrackerErrorCallback(torrent_TrackerError); }
private void openMenuItem_Click(object sender, System.EventArgs e) { WinForms.OpenFileDialog dialog = new WinForms.OpenFileDialog(); dialog.Title = "Open torrent file"; dialog.Filter = @"Torrent file (*.torrent)|*.torrent|All files (*.*)|*.*"; if (dialog.ShowDialog(this) == WinForms.DialogResult.OK) { BT.Torrent torrent = btsession.CreateTorrent( dialog.FileName ); this.torrentListView.Items.Add(new TorrentListViewItem(torrent)); torrent.PeerConnected += new BT.TorrentPeerConnectedCallback(OnPeerConnected); torrent.CheckFileIntegrity( true ); torrent.Start(); } }
public static void OnCheckIntegrity(Torrent torrent, int pieceId, bool good, float percentDone) { Console.WriteLine("Piece: " + pieceId + " Good: " + good + " Percent: " + percentDone); }
internal void loadTorrentFileInfo(string torrentFilePath) { try { currentTorrentFile = new Torrent(torrentFilePath); torrentFile.Text = torrentFilePath; trackerAddress.Text = currentTorrentFile.Announce; shaHash.Text = ToHexString(currentTorrentFile.InfoHash); // text.Text = currentTorrentFile.totalLength.ToString(); txtTorrentSize.Text = FormatFileSize((currentTorrentFile.totalLength)); } catch (Exception ex) { AddLogLine(ex.ToString()); } }
public Torrent CreateTorrent( string metafilename ) { Torrent torrent = new Torrent( this, metafilename ); mTorrents.Add( torrent ); return torrent; }
/// <summary> /// Constructs a TrackerProtocol /// </summary> public TrackerProtocol(Torrent torrent, MetainfoFile infofile, DownloadFile file) { this.torrent = torrent; this.infofile = infofile; this.file = file; }
private void torrent_TrackerError(BT.Torrent torrent, string message) { this.ListView.BeginInvoke(new UpdateSubItemTextDelegate(UpdateSubItemText), new object[] { 3, message }); }
private void OnTorrentChangeStatus(BT.Torrent torrent, BT.TorrentStatus status) { this.ListView.BeginInvoke(new UpdateSubItemTextDelegate(UpdateSubItemText), new object[] { 1, status.ToString() }); }
public Peer(Torrent torrent, string localId, IPEndPoint endPoint) : this(torrent, localId) { IPEndPoint = endPoint; }
public Peer(Torrent torrent, string localId, TcpClient client) : this(torrent, localId) { TcpClient = client; IPEndPoint = (IPEndPoint)client.Client.RemoteEndPoint; }
private Peer(Torrent torrent, string localId) { LocalId = localId; Torrent = torrent; LastActive = DateTime.UtcNow; IsPieceDownloaded = new bool[Torrent.PieceCount]; IsBlockRequested = new bool[Torrent.PieceCount][]; for (int i = 0; i < Torrent.PieceCount; i++) IsBlockRequested[i] = new bool[Torrent.GetBlockCount(i)]; }
public DownloadStrategyManager( Torrent torrent ) { this.mTorrent = torrent; this.mPieceCounter = new PieceCounter( this.mTorrent.PieceCount ); }