Permalink
Browse files

Merge pull request #15 from kellyelton/patch-1

Couple mistakes, like event delegate being registered in the wrong spot,...
  • Loading branch information...
alanmcgovern committed Jun 12, 2012
2 parents ea8e3dc + 06fc438 commit 36d3b44c50dad03da83351be5a3807354131e31d
Showing with 15 additions and 29 deletions.
  1. +15 −29 src/DhtSampleClient/Program.cs
@@ -21,41 +21,27 @@ static void Main(string[] args)
nodes = File.ReadAllBytes("mynodes");
listener.Start();
+ engine.PeersFound += delegate(object o, PeersFoundEventArgs e) {
+ Console.WriteLine("I FOUND PEERS: {0}", e.Peers.Count);
engine.Start(nodes);
Random random = new Random(5);
byte[] b = new byte[20];
lock (random)
random.NextBytes(b);
-
- for (int i = 0; i < 30; i++)
- {
- Console.WriteLine("Waiting: {0} seconds left", (30 - i));
- System.Threading.Thread.Sleep(1000);
- }
-
- // Get some peers for the torrent
- engine.GetPeers(b);
-
- engine.PeersFound += delegate(object o, PeersFoundEventArgs e) {
- Console.WriteLine("I FOUND PEERS: {0}", e.Peers.Count);
- };
-
- for (int i = 0; i < 30; i++)
- {
- Console.WriteLine("Waiting: {0} seconds left", (30 - i));
- System.Threading.Thread.Sleep(1000);
- }
-
- // Add ourself to the DHT so people know we have the torrent too
- //engine.Announce(t.infoHash, 25000);
-
- while (Console.ReadLine() != "q")
- {
- random.NextBytes(b);
- engine.GetPeers(b);
- }
+
+ while(Console.ReadLine() != "q")
+ {
+ for (int i = 0; i < 30; i++)
+ {
+ Console.WriteLine("Waiting: {0} seconds left", (30 - i));
+ System.Threading.Thread.Sleep(1000);
+ }
+ // Get some peers for the torrent
+ engine.GetPeers(b);
+ random.NextBytes(b);
+ }
File.WriteAllBytes("mynodes", engine.SaveNodes());
}
}
-}
+}

0 comments on commit 36d3b44

Please sign in to comment.