コード例 #1
0
ファイル: Piece.cs プロジェクト: dvillaseca/RatioMaster.NET
        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);
        }
コード例 #2
0
ファイル: session.cs プロジェクト: peteward44/torrent.net
		public void AddTorrent( Torrent torrent )
		{
			mTorrents.Enqueue( torrent );
			if ( !mInProgress )
			{
				mInProgress = true;
				if ( mUseThread )
					Threading.ThreadPool.QueueUserWorkItem( new Threading.WaitCallback( PrivateStart ) );
				else
					PrivateStart( null );
			}
		}
コード例 #3
0
	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 );
		}
	}
コード例 #4
0
    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);
    }
コード例 #5
0
	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);
	}
コード例 #6
0
	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();
		}
	}
コード例 #7
0
ファイル: entrypoint.cs プロジェクト: peteward44/torrent.net
	public static void OnCheckIntegrity(Torrent torrent, int pieceId, bool good, float percentDone)
	{
		Console.WriteLine("Piece: " + pieceId + " Good: " + good + " Percent: " + percentDone);
	}
コード例 #8
0
ファイル: RM.cs プロジェクト: NikolayIT/RatioMaster.NET
        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());
            }
        }
コード例 #9
0
ファイル: session.cs プロジェクト: peteward44/torrent.net
		public Torrent CreateTorrent( string metafilename )
		{
			Torrent torrent = new Torrent( this, metafilename );
			mTorrents.Add( torrent );
			return torrent;
		}
コード例 #10
0
		/// <summary>
		/// Constructs a TrackerProtocol
		/// </summary>
		public TrackerProtocol(Torrent torrent, MetainfoFile infofile, DownloadFile file)
		{
			this.torrent = torrent;
			this.infofile = infofile;
			this.file = file;
		}
コード例 #11
0
 private void torrent_TrackerError(BT.Torrent torrent, string message)
 {
     this.ListView.BeginInvoke(new UpdateSubItemTextDelegate(UpdateSubItemText), new object[] { 3, message });
 }
コード例 #12
0
 private void OnTorrentChangeStatus(BT.Torrent torrent, BT.TorrentStatus status)
 {
     this.ListView.BeginInvoke(new UpdateSubItemTextDelegate(UpdateSubItemText), new object[] { 1, status.ToString() });
 }
コード例 #13
0
 public Peer(Torrent torrent, string localId, IPEndPoint endPoint)
     : this(torrent, localId)
 {
     IPEndPoint = endPoint;
 }
コード例 #14
0
 public Peer(Torrent torrent, string localId, TcpClient client)
     : this(torrent, localId)
 {
     TcpClient = client;
     IPEndPoint = (IPEndPoint)client.Client.RemoteEndPoint;
 }
コード例 #15
0
        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)];
        }
コード例 #16
0
		public DownloadStrategyManager( Torrent torrent )
		{
			this.mTorrent = torrent;
			this.mPieceCounter = new PieceCounter( this.mTorrent.PieceCount );
		}