当前位置: 首页>>代码示例>>C#>>正文


C# TorrentManager类代码示例

本文整理汇总了C#中TorrentManager的典型用法代码示例。如果您正苦于以下问题:C# TorrentManager类的具体用法?C# TorrentManager怎么用?C# TorrentManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TorrentManager类属于命名空间,在下文中一共展示了TorrentManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TrackerPeersAdded

        public TrackerPeersAdded(TorrentManager manager, int peersAdded, int total, MonoTorrent.Client.Tracker.Tracker tracker)
            :base (manager, peersAdded, total)
        {
            if (tracker == null)
                throw new ArgumentNullException("tracker");

            this.tracker = tracker;
        }
开发者ID:dontnod,项目名称:monotorrent,代码行数:8,代码来源:TrackerPeersAdded.cs

示例2: TorrentStreamManager

        public TorrentStreamManager(TorrentManager torrentManager, long prepareSize = 10*1024L*1024L)
        {
            TorrentManager = torrentManager;
            _prepareSize = prepareSize;

            TorrentManager.TorrentStateChanged += TorrentManager_TorrentStateChanged;
        }
开发者ID:haroldma,项目名称:PopcornTime,代码行数:7,代码来源:TorrentStreamManager.cs

示例3: ChokeUnchokeManager

 /// <summary>
 ///     Initializes a new instance of the <see cref="ChokeUnchokeManager" /> class.
 /// </summary>
 /// <param name="torrentManager">The torrent manager.</param>
 /// <param name="minimumTimeBetweenReviews">The minimum time between reviews.</param>
 /// <param name="percentOfMaxRateToSkipReview">The percent of maximum rate to skip review.</param>
 public ChokeUnchokeManager(TorrentManager torrentManager, int minimumTimeBetweenReviews,
     int percentOfMaxRateToSkipReview)
 {
     _owningTorrent = torrentManager;
     _minimumTimeBetweenReviews = minimumTimeBetweenReviews;
     _percentOfMaxRateToSkipReview = percentOfMaxRateToSkipReview;
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:13,代码来源:ChokeUnchokeManager.cs

示例4: PieceMessage

 public PieceMessage(TorrentManager manager, int pieceIndex, int startOffset, int blockLength)
 {
     this.manager = manager;
     this.pieceIndex = pieceIndex;
     this.startOffset = startOffset;
     this.requestLength = blockLength;
 }
开发者ID:burris,项目名称:monotorrent,代码行数:7,代码来源:PieceMessage.cs

示例5: DecodeMessage

        public static PeerMessage DecodeMessage(byte[] buffer, int offset, int count, TorrentManager manager)
        {
            PeerMessage message;
            CreateMessage creator;

            if (count < 4)
                throw new ArgumentException("A message must contain a 4 byte length prefix");

            int messageLength = IPAddress.HostToNetworkOrder(BitConverter.ToInt32(buffer, offset));

            if (messageLength > (count - 4))
                throw new ArgumentException("Incomplete message detected");

            if (buffer[offset + 4] == ExtensionMessage.MessageId)
                return ExtensionMessage.DecodeMessage(buffer, offset + 4 + 1, count - 4 - 1, manager);

            if (!messageDict.TryGetValue(buffer[offset + 4], out creator))
                throw new ProtocolException("Unknown message received");

            // The message length is given in the second byte and the message body follows directly after that
            // We decode up to the number of bytes Received. If the message isn't complete, throw an exception
            message = creator(manager);
            message.Decode(buffer, offset + 4 + 1, count - 4 - 1);
            return message;
        }
开发者ID:ballance,项目名称:MetroTorrent,代码行数:25,代码来源:PeerMessage.cs

示例6: StoppingMode

        public StoppingMode(TorrentManager manager)
            : base(manager)
        {
            CanAcceptConnections = false;
            var engine = manager.Engine;

            var hashingMode = manager.Mode as HashingMode;
            if (hashingMode != null)
                _handle.AddHandle(hashingMode.HashingWaitHandle, "Hashing");

            if (manager.TrackerManager.CurrentTracker != null)
                _handle.AddHandle(manager.TrackerManager.Announce(TorrentEvent.Stopped), "Announcing");

            foreach (var id in manager.Peers.ConnectedPeers.Where(id => id.Connection != null))
                id.Connection.Dispose();

            manager.Peers.ClearAll();

            _handle.AddHandle(engine.DiskManager.CloseFileStreams(manager), "DiskManager");

            manager.Monitor.Reset();
            manager.PieceManager.Reset();
            engine.ConnectionManager.CancelPendingConnects(manager);
            engine.Stop();
        }
开发者ID:Eskat0n,项目名称:OctoTorrent,代码行数:25,代码来源:StoppingMode.cs

示例7: ChokeUnchokeManager

        private DateTime timeOfLastReview; //When we last reviewed the choke/unchoke position

        #endregion Fields

        #region Constructors

        /// <summary>
        ///     Creates a new choke/unchoke manager for a torrent manager
        ///     </summeary>
        ///     <param name="TorrentManager">The torrent manager this choke/unchoke manager belongs to</param>
        public ChokeUnchokeManager(TorrentManager TorrentManager, int MinimumTimeBetweenReviews,
			int PercentOfMaxRateToSkipReview)
        {
            owningTorrent = TorrentManager;
            minimumTimeBetweenReviews = MinimumTimeBetweenReviews;
            percentOfMaxRateToSkipReview = PercentOfMaxRateToSkipReview;
        }
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:17,代码来源:ChokeUnchokeManager.cs

示例8: AddConnection

        public void AddConnection(TorrentConnection connection, TorrentManager manager)
        {
            string remoteId = String.Empty;

            LoggingService.LogDebug("AddConnection(): Start");

            if (!connection.IsIncoming) {
                // Send my identity.
                // XXX: This absolutely needs to be signed.
                connection.Transport.SendMessage(System.Text.Encoding.ASCII.GetBytes(Core.MyNodeID));

                // Get other end's identity.
                byte[] message = connection.Transport.ReceiveMessage();
                remoteId = System.Text.Encoding.ASCII.GetString(message);

            } else {
                // Get other end's identity.
                byte[] message = connection.Transport.ReceiveMessage();
                remoteId = System.Text.Encoding.ASCII.GetString(message);

                // Send my identity.
                // XXX: This absolutely needs to be signed.
                connection.Transport.SendMessage(System.Text.Encoding.ASCII.GetBytes(Core.MyNodeID));
            }

            LoggingService.LogDebug("Pushing connection to engine: {0} - {1}", connection.IsIncoming ? "Incoming" : "Outgoing",
                              ((Meshwork.Transport.TcpTransport)connection.Transport).RemoteEndPoint.ToString());

            Peer p = new Peer("", new Uri(String.Format("meshwork:{0}", remoteId)), EncryptionTypes.PlainText);
            RaiseConnectionReceived(p, connection, manager);

            LoggingService.LogDebug("AddConnection(): End");
        }
开发者ID:codebutler,项目名称:meshwork,代码行数:33,代码来源:MeshworkPeerConnectionListener.cs

示例9: PeerConnectionFailedEventArgs

 /// <summary>
 ///     Create new instance of PeerConnectionFailedEventArgs for peer from given torrent.
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="peer"></param>
 /// <param name="direction">Which direction the connection attempt was</param>
 /// <param name="message">Message associated with the failure</param>
 public PeerConnectionFailedEventArgs(TorrentManager manager, Peer peer, Direction direction, String message)
     : base(manager)
 {
     this.peer = peer;
     connectionDirection = direction;
     this.message = message;
 }
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:14,代码来源:PeerConnectionFailedEventArgs.cs

示例10: StoppingMode

        public StoppingMode(TorrentManager manager)
            : base(manager)
        {
            CanAcceptConnections = false;
            var engine = manager.Engine;
            if (manager.Mode is HashingMode)
                handle.AddHandle(((HashingMode) manager.Mode).hashingWaitHandle, "Hashing");

            if (manager.TrackerManager.CurrentTracker != null &&
                manager.TrackerManager.CurrentTracker.Status == TrackerState.Ok)
                handle.AddHandle(manager.TrackerManager.Announce(TorrentEvent.Stopped), "Announcing");

            foreach (var id in manager.Peers.ConnectedPeers)
                if (id.Connection != null)
                    id.Connection.Dispose();

            manager.Peers.ClearAll();

            handle.AddHandle(engine.DiskManager.CloseFileStreams(manager), "DiskManager");

            manager.Monitor.Reset();
            manager.PieceManager.Reset();
            engine.ConnectionManager.CancelPendingConnects(manager);
            engine.Stop();
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:25,代码来源:StoppingMode.cs

示例11: AsyncConnectState

 public AsyncConnectState(TorrentManager manager, Peer peer, IConnection connection, AsyncConnect callback)
 {
     Manager = manager;
     Peer = peer;
     Connection = connection;
     Callback = callback;
 }
开发者ID:burris,项目名称:monotorrent,代码行数:7,代码来源:NetworkIO.cs

示例12: AddTorrent

 public void AddTorrent(string path)
 {
     Torrent torrent = Torrent.Load(path);
     TorrentManager manager = new TorrentManager(torrent, downloadsPath, defaultSettings);
     engine.Register(manager);
     managerCollection.Add(manager);
 }
开发者ID:descention,项目名称:LAN-CDS,代码行数:7,代码来源:Transfer.cs

示例13: PeerMessageEventArgs

 /// <summary>
 /// Creates a new PeerMessageEventArgs
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="message">The peer message involved</param>
 /// <param name="direction">The direction of the message</param>
 /// <param name="id">The identifier.</param>
 internal PeerMessageEventArgs(TorrentManager manager, PeerMessage message, Direction direction, PeerId id)
     : base(manager)
 {
     Direction = direction;
     ID = id;
     Message = message;
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:14,代码来源:MessageEventArgs.cs

示例14: Start

		public void Start()
		{
			foreach (string file in Directory.GetFiles(downloadsPath, "*.torrent"))
			{
				Torrent torrent = Torrent.Load(file);
				string savePath = Path.Combine(downloadsPath, torrent.Name);
				var manager = new TorrentManager(torrent, savePath, new TorrentSettings());
				manager.TorrentStateChanged +=
					delegate(object sender, TorrentStateChangedEventArgs e)
					{
							if(e.NewState==TorrentState.Seeding)
							{
								ReportSeeding(e.TorrentManager.Torrent.Name);
							}
						 Console.WriteLine("Torrent {0} changed: {1} -> {2}", e.TorrentManager.Torrent.Name, e.OldState, e.NewState);
					};
				manager.PeerConnected +=
					delegate(object sender, PeerConnectionEventArgs e)
					{
						Console.WriteLine("Peer {2} connect to: {0} as {1}", e.TorrentManager.Torrent.Name, e.ConnectionDirection,
						                  e.PeerID.Location);
					};
				engine.Register(manager);
			}
			engine.StartAll();
			WaitForDisposable.WaitOne();
		}
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:27,代码来源:TorrentServer.cs

示例15: TorrentHandler

 public TorrentHandler(TorrentManager tm)
 {
     TorrentManager = tm;
     _delete = new List<string>();
     _files = new List<FileInfo>();
     _files.AddRange(Directory.GetFiles(tm.SavePath, "*.*", SearchOption.AllDirectories).Select(o => new FileInfo(o)));
 }
开发者ID:csyolen,项目名称:Jarvis,代码行数:7,代码来源:TorrentHandler.cs


注:本文中的TorrentManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。