本文整理汇总了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);
}
}
示例2: ClosingTrackerClosesSocket
public void ClosingTrackerClosesSocket()
{
tracker = new Tracker(file, socket);
tracker.Start();
Assert.IsTrue(socket.Connected);
tracker.Close();
Assert.IsFalse(socket.Connected);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}