• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TorrentManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Mode

 protected Mode(TorrentManager manager)
 {
     CanAcceptConnections = true;
     this.manager = manager;
     manager.chokeUnchoker = new ChokeUnchokeManager(manager, manager.Settings.MinimumTimeBetweenReviews,
         manager.Settings.PercentOfMaxRateToSkipReview);
 }
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:7,代码来源:Mode.cs


示例17: PeerMessageEventArgs

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


示例18: PausedMode

 public PausedMode(TorrentManager manager)
     : base(manager)
 {
     // When in the Paused mode, a special RateLimiter will
     // activate and disable transfers. PauseMode itself
     // does not need to do anything special.
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:7,代码来源:PausedMode.cs


示例19: InitialSeedingMode

 public InitialSeedingMode(TorrentManager manager)
     : base(manager)
 {
     unchoker = new InitialSeedUnchoker(manager);
     manager.chokeUnchoker = unchoker;
     zero = new BitField(manager.Bitfield.Length);
 }
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:7,代码来源:InitialSeedingMode.cs


示例20: PeerConnectionEventArgs

 internal PeerConnectionEventArgs(TorrentManager manager, PeerId id, Direction direction, string message)
     : base(manager)
 {
     PeerID = id;
     ConnectionDirection = direction;
     Message = message;
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:7,代码来源:PeerConnectionEventArgs.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Touch类代码示例发布时间:2022-05-24
下一篇:
C# TorrentFile类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap