Show / Hide Table of Contents

Class TorrentManager

Inheritance
System.Object
TorrentManager
Implements
System.IEquatable<TorrentManager>
ITorrentData
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: MonoTorrent.Client
Assembly: MonoTorrent.dll
Syntax
public class TorrentManager : IEquatable<TorrentManager>, ITorrentData

Properties

Bitfield

Declaration
public BitField Bitfield { get; }
Property Value
Type Description
BitField

CanUseDht

Declaration
public bool CanUseDht { get; }
Property Value
Type Description
System.Boolean

CanUseLocalPeerDiscovery

Declaration
public bool CanUseLocalPeerDiscovery { get; }
Property Value
Type Description
System.Boolean

Complete

Returns true only when all files have been fully downloaded. If some files are marked as 'DoNotDownload' then the torrent will not be considered to be Complete until they are downloaded.

Declaration
public bool Complete { get; }
Property Value
Type Description
System.Boolean

Engine

Declaration
public ClientEngine Engine { get; }
Property Value
Type Description
ClientEngine

Error

Declaration
public Error Error { get; }
Property Value
Type Description
Error

Files

Declaration
public IList<ITorrentFileInfo> Files { get; }
Property Value
Type Description
System.Collections.Generic.IList<ITorrentFileInfo>

HashChecked

Declaration
public bool HashChecked { get; }
Property Value
Type Description
System.Boolean

HashFails

Declaration
public int HashFails { get; }
Property Value
Type Description
System.Int32

HasMetadata

Declaration
public bool HasMetadata { get; }
Property Value
Type Description
System.Boolean

InfoHash

Declaration
public InfoHash InfoHash { get; }
Property Value
Type Description
InfoHash

IsInEndGame

True if this torrent has activated special processing for the final few pieces

Declaration
public bool IsInEndGame { get; }
Property Value
Type Description
System.Boolean

IsInitialSeeding

Declaration
public bool IsInitialSeeding { get; }
Property Value
Type Description
System.Boolean

LastDhtAnnounce

The time the last announce to the DHT occurred

Declaration
public DateTime LastDhtAnnounce { get; }
Property Value
Type Description
System.DateTime

LastLocalPeerAnnounce

The time the last announce using Local Peer Discovery occurred

Declaration
public DateTime LastLocalPeerAnnounce { get; }
Property Value
Type Description
System.DateTime

MagnetLink

Declaration
public MagnetLink MagnetLink { get; }
Property Value
Type Description
MagnetLink

MetadataPath

The path to the .torrent metadata used to create the TorrentManager. Typically stored within the MetadataCacheDirectory directory.

Declaration
public string MetadataPath { get; }
Property Value
Type Description
System.String

Monitor

Declaration
public ConnectionMonitor Monitor { get; }
Property Value
Type Description
ConnectionMonitor

OpenConnections

The number of peers that this torrent instance is connected to

Declaration
public int OpenConnections { get; }
Property Value
Type Description
System.Int32

PartialProgress

The download progress in percent (0 -> 100.0) for the files whose priority is not set to DoNotDownload. If every file is marked as DoNotDownload then this returns 0. If no file is marked as 'DoNotDownload' then this returns the same value as Progress.

Declaration
public double PartialProgress { get; }
Property Value
Type Description
System.Double

Peers

Declaration
public PeerManager Peers { get; }
Property Value
Type Description
PeerManager

PieceLength

Declaration
public int PieceLength { get; }
Property Value
Type Description
System.Int32

PieceManager

The piecemanager for this TorrentManager

Declaration
public PieceManager PieceManager { get; }
Property Value
Type Description
PieceManager

Progress

The download progress in percent (0 -> 100.0). This includes all files, even if they are marked as DoNotDownload. This will return '100.0' when all files in the torrent have been downloaded.

Declaration
public double Progress { get; }
Property Value
Type Description
System.Double

SavePath

The directory to download the files to

Declaration
public string SavePath { get; }
Property Value
Type Description
System.String

Settings

The settings for with this TorrentManager

Declaration
public TorrentSettings Settings { get; }
Property Value
Type Description
TorrentSettings

Size

Declaration
public long Size { get; }
Property Value
Type Description
System.Int64

StartTime

The time the torrent manager was started at

Declaration
public DateTime StartTime { get; }
Property Value
Type Description
System.DateTime

State

The current state of the TorrentManager

Declaration
public TorrentState State { get; }
Property Value
Type Description
TorrentState

StreamProvider

When a Torrent or MagnetLink has been added using the 'AddStreamingAsync' methods on ClientEngine then this property will be non-null and streams can be created to access any of the files in the torrent while they are downloading. These streams are fully seekable, and if you seek to a position which has not been downloaded already the required pieces will be prioritised next.

Declaration
public StreamProvider StreamProvider { get; }
Property Value
Type Description
StreamProvider

Torrent

The Torrent contained within this TorrentManager

Declaration
public Torrent Torrent { get; }
Property Value
Type Description
Torrent

TrackerManager

The tracker connection associated with this TorrentManager

Declaration
public ITrackerManager TrackerManager { get; }
Property Value
Type Description
ITrackerManager

UploadingTo

The number of peers that we are currently uploading to

Declaration
public int UploadingTo { get; }
Property Value
Type Description
System.Int32

Methods

AddPeerAsync(Peer)

Declaration
public Task<bool> AddPeerAsync(Peer peer)
Parameters
Type Name Description
Peer peer
Returns
Type Description
System.Threading.Tasks.Task<System.Boolean>

AddPeersAsync(IEnumerable<Peer>)

Declaration
public Task<int> AddPeersAsync(IEnumerable<Peer> peers)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<Peer> peers
Returns
Type Description
System.Threading.Tasks.Task<System.Int32>

ChangePickerAsync(IPieceRequester)

Changes the active piece picker. This can be called when the manager is running, or when it is stopped.

Declaration
public Task ChangePickerAsync(IPieceRequester requester)
Parameters
Type Name Description
IPieceRequester requester

The new picker to use.

Returns
Type Description
System.Threading.Tasks.Task

DhtAnnounceAsync()

Perform an announce using the DhtEngine to retrieve more peers. The returned task completes as soon as the Dht announce begins.

Declaration
public Task DhtAnnounceAsync()
Returns
Type Description
System.Threading.Tasks.Task

Equals(TorrentManager)

Declaration
public bool Equals(TorrentManager other)
Parameters
Type Name Description
TorrentManager other
Returns
Type Description
System.Boolean

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.Object.Equals(System.Object)

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()

GetPeersAsync()

Declaration
public Task<List<PeerId>> GetPeersAsync()
Returns
Type Description
System.Threading.Tasks.Task<System.Collections.Generic.List<PeerId>>

HashCheckAsync(Boolean)

Performs a full hash check, ignoring any previously loaded Fast Resume data or previous hash checks.

Declaration
public Task HashCheckAsync(bool autoStart)
Parameters
Type Name Description
System.Boolean autoStart

True if a the TorrentManager should be started as soon as the hashcheck completes.

Returns
Type Description
System.Threading.Tasks.Task

LoadFastResume(FastResume)

Declaration
public void LoadFastResume(FastResume data)
Parameters
Type Name Description
FastResume data

LocalPeerAnnounceAsync()

Declaration
public Task LocalPeerAnnounceAsync()
Returns
Type Description
System.Threading.Tasks.Task

MoveFileAsync(ITorrentFileInfo, String)

Declaration
public Task MoveFileAsync(ITorrentFileInfo file, string path)
Parameters
Type Name Description
ITorrentFileInfo file
System.String path
Returns
Type Description
System.Threading.Tasks.Task

MoveFilesAsync(String, Boolean)

Declaration
public Task MoveFilesAsync(string newRoot, bool overWriteExisting)
Parameters
Type Name Description
System.String newRoot
System.Boolean overWriteExisting
Returns
Type Description
System.Threading.Tasks.Task

PauseAsync()

Pauses the TorrentManager

Declaration
public Task PauseAsync()
Returns
Type Description
System.Threading.Tasks.Task

SaveFastResume()

Declaration
public FastResume SaveFastResume()
Returns
Type Description
FastResume

SetFilePriorityAsync(ITorrentFileInfo, Priority)

Declaration
public Task SetFilePriorityAsync(ITorrentFileInfo file, Priority priority)
Parameters
Type Name Description
ITorrentFileInfo file
Priority priority
Returns
Type Description
System.Threading.Tasks.Task

SetNeedsHashCheckAsync()

Marks the TorrentManager as needing a full hash check. If AutoSaveLoadFastResume is enabled this method will also delete fast resume data from the location specified by GetFastResumePath(InfoHash). This can only be invoked when the State is Stopped.

Declaration
public Task SetNeedsHashCheckAsync()
Returns
Type Description
System.Threading.Tasks.Task

StartAsync()

Starts the TorrentManager

Declaration
public Task StartAsync()
Returns
Type Description
System.Threading.Tasks.Task

StopAsync()

Stops the TorrentManager. The returned task completes as soon as the manager has fully stopped.

Declaration
public Task StopAsync()
Returns
Type Description
System.Threading.Tasks.Task

StopAsync(TimeSpan)

Stops the TorrentManager. The returned task completes as soon as the manager has fully stopped. The final tracker announce will be limited to the maximum of either 2 seconds or timeout seconds.

Declaration
public Task StopAsync(TimeSpan timeout)
Parameters
Type Name Description
System.TimeSpan timeout
Returns
Type Description
System.Threading.Tasks.Task

ToString()

Overrridden. Returns the name of the torrent.

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()

UpdateSettingsAsync(TorrentSettings)

Declaration
public Task UpdateSettingsAsync(TorrentSettings settings)
Parameters
Type Name Description
TorrentSettings settings
Returns
Type Description
System.Threading.Tasks.Task

WaitForMetadataAsync()

Waits for the metadata to be available

Declaration
public Task WaitForMetadataAsync()
Returns
Type Description
System.Threading.Tasks.Task

WaitForMetadataAsync(CancellationToken)

Declaration
public Task WaitForMetadataAsync(CancellationToken token)
Parameters
Type Name Description
System.Threading.CancellationToken token
Returns
Type Description
System.Threading.Tasks.Task

Events

ConnectionAttemptFailed

This asynchronous event is raised when an outgoing connection to a peer could not be established.

Declaration
public event EventHandler<ConnectionAttemptFailedEventArgs> ConnectionAttemptFailed
Event Type
Type Description
System.EventHandler<ConnectionAttemptFailedEventArgs>

PeerConnected

This asynchronous event is raised whenever a new incoming, or outgoing, connection has successfully completed the handshake process and has been fully established.

Declaration
public event EventHandler<PeerConnectedEventArgs> PeerConnected
Event Type
Type Description
System.EventHandler<PeerConnectedEventArgs>

PeerDisconnected

This asynchronous event is raised whenever an established connection has been closed.

Declaration
public event EventHandler<PeerDisconnectedEventArgs> PeerDisconnected
Event Type
Type Description
System.EventHandler<PeerDisconnectedEventArgs>

PeersFound

Raised whenever new peers are discovered and added. The object will be of type TrackerPeersAdded, PeerExchangePeersAdded, LocalPeersAdded or DhtPeersAdded depending on the source of the new peers.

Declaration
public event EventHandler<PeersAddedEventArgs> PeersFound
Event Type
Type Description
System.EventHandler<PeersAddedEventArgs>

PieceHashed

This asynchronous event is raised whenever a piece is hashed, either as part of regular downloading, or as part of a HashCheckAsync(Boolean).

Declaration
public event EventHandler<PieceHashedEventArgs> PieceHashed
Event Type
Type Description
System.EventHandler<PieceHashedEventArgs>

TorrentStateChanged

This asynchronous event is raised whenever the TorrentManager changes state.

Declaration
public event EventHandler<TorrentStateChangedEventArgs> TorrentStateChanged
Event Type
Type Description
System.EventHandler<TorrentStateChangedEventArgs>

Implements

System.IEquatable<T>
ITorrentData

Extension Methods

ITorrentDataExtensions.BlocksPerPiece(ITorrentData, Int32)
ITorrentDataExtensions.BytesPerPiece(ITorrentData, Int32)
ITorrentDataExtensions.ByteOffsetToPieceIndex(ITorrentData, Int64)
ITorrentDataExtensions.PieceCount(ITorrentData)
ITorrentDataExtensions.PieceIndexToByteOffset(ITorrentData, Int32)
In This Article
Back to top Generated by DocFX