Managing Torrents

Version 2 (olivier dufour, 04/08/2009 08:58 AM)

1 1
h1. Client example
2 1
3 2 olivier dufour
<pre><code class="csharp">
4 1
5 2 olivier dufour
6 1
ClientEngine engine = new ClientEngine(new EngineSettings(downloadsPath, port));
7 1
8 1
//DHT
9 1
DhtListener dhtListner = new UdpListener (new IPEndPoint (IPAddress.Any, port));
10 1
DhtEngine dht = new DhtEngine (dhtListner);
11 1
engine.RegisterDht(dht);
12 1
dhtListner.Start();
13 1
//byte array of dht nodes 
14 1
engine.DhtEngine.Start(nodes);
15 1
16 1
17 1
torrent = Torrent.Load("test.torrent");
18 1
TorrentManager manager = new TorrentManager(torrent, downloadsPath, torrentDefaults);
19 1
20 1
//FastResume code need a BencodedDictionnary
21 1
manager.LoadFastResume(new FastResume (BEncDictFastResume));
22 1
23 1
engine.Register(manager);
24 1
manager.Start ();
25 1
26 1
</code>
27 2 olivier dufour
</pre>