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


C# Tracker.Start方法代码示例

本文整理汇总了C#中Tracker.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Tracker.Start方法的具体用法?C# Tracker.Start怎么用?C# Tracker.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tracker的用法示例。


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

示例1: Main

 static void Main(string[] args)
 {
     Torrent torrent = new Torrent(BenDecoder.Decode(args[0]));
     Tracker trackerClient = new Tracker(torrent);
     Console.WriteLine("Connecting to tracker at {0}", torrent.AnnounceUri);
     object cv = new object();
     trackerClient.Connected += delegate
         {
             Console.WriteLine("Connected to {0}", torrent.AnnounceUri);
         };
     trackerClient.Updated += delegate
         {
             if(trackerClient.LastResponse.IsSuccessful)
             {
                 Console.WriteLine("{0} Seeders, {1} leechers", trackerClient.LastResponse.NumberOfSeeds, trackerClient.LastResponse.NumberOfLeechers);
                 ConnectToPeers(trackerClient.LastResponse.Peers, torrent);
             }
             else
             {
                 QuitWithError(cv, trackerClient.LastResponse.FailureReason);
             }
            
         };
     trackerClient.Error += delegate(object sender, Exception e)
         {
             QuitWithError(cv, e.Message);
         };
     trackerClient.Start();
     lock(cv)
     {
         Monitor.Wait(cv);
     }
 }
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:33,代码来源:Program.cs

示例2: ClosingTrackerClosesSocket

 public void ClosingTrackerClosesSocket()
 {
     tracker = new Tracker(file, socket);
     tracker.Start();
     Assert.IsTrue(socket.Connected);
     tracker.Close();
     Assert.IsFalse(socket.Connected);
 }
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:8,代码来源:TrackerTests.cs

示例3: ReceiveResponse

 public void ReceiveResponse()
 {
     tracker = new Tracker(file, socket);
     bool responseReceived = false;
     tracker.Updated += delegate(object sender, EventArgs e)
         {
             responseReceived = true;
             Assert.IsTrue(tracker.LastResponse.IsSuccessful);
         };
     tracker.Start();
     Assert.IsTrue(responseReceived);
 }
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:12,代码来源:TrackerTests.cs

示例4: HandleError

 public void HandleError()
 {
     FakeErrorSocket fakeSocket = new FakeErrorSocket();
     fakeSocket.ErrorOnConnect = true;
     tracker = new Tracker(file, fakeSocket);
     bool errorReceived = false;
     tracker.Error += delegate(object sender, Exception se)
         {
             errorReceived = true;
             Assert.IsNotNull(se);
         };
     tracker.Start();
     Assert.IsTrue(errorReceived);
 }
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:14,代码来源:TrackerTests.cs

示例5: Tracker

        IPointerTracker IPointerHandler.TrackPointer(PointerPosition position)
        {
            IPointerTracker newTracker = null;

            if(null == _tracker)
            {
                Tracker tracker = new Tracker(this, _synthesizer);

                _tracker = tracker;
                newTracker = tracker;
                tracker.Start(position);
            }

            return newTracker;
        }
开发者ID:pwkpwk,项目名称:Audiogen,代码行数:15,代码来源:PointerHandler.cs

示例6: SendStartedMessage

 public void SendStartedMessage()
 {
     tracker = new Tracker(file, socket);
     bool connected = false;
     tracker.Connected += delegate(object sender, EventArgs e)
         {
             connected = true;
         };
     ByteString expectedMessage = new ByteString("GET /announce?info_hash=%cdt%feF%cc%a3%a0%e6%dc_%f7%1c%bd%82%82ljZ%5d%3e&" +
                                                 "peer_id=12345678901234567890&port=6881&compact=1&uploaded=0&downloaded=0&left=3706908089&event=started HTTP/1.1\r\n\r\n");
     tracker.Start();
     Assert.IsTrue(socket.Connected);
     Assert.IsTrue(connected);
     Assert.AreEqual(expectedMessage, socket.lastMessage);
 }
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:15,代码来源:TrackerTests.cs

示例7: ConnectToTracker

 private void ConnectToTracker()
 {
     if(tracker != null)
     {
         tracker.Close();
     }
     tracker = new Tracker(torrent);
     tracker.Error += new Tracker.TrackerErrorHandler(tracker_Error);
     trackerStatus.Text = "Connecting...";
     tracker.Connected += delegate(object sender, EventArgs arg)
         {
             MethodInvoker invoker = new MethodInvoker(delegate ()
                 {
                     trackerStatus.Text = "Updating...";
                 });
             Invoke(invoker);
         };
     tracker.Updated += delegate(object sender, EventArgs arg)
        {
            MethodInvoker invoker = new MethodInvoker(delegate()
                {
                    if (tracker.LastResponse.IsSuccessful)
                    {
                        trackerStatus.Text = "OK";
                        swarmSize.Text = string.Format("Peers: {0}     Seeds: {1}", tracker.LastResponse.NumberOfLeechers, tracker.LastResponse.NumberOfSeeds);
                        UpdatePeerList();
                    }
                    else
                    {
                        trackerStatus.Text = string.Format("Error: {0}", tracker.LastResponse.FailureReason);
                    }
                    
                });
            Invoke(invoker);
        };
     tracker.Start();
 }
开发者ID:worldspuppet,项目名称:torrentnet,代码行数:37,代码来源:TrackerProbe.cs


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