Skip to content

Commit

Permalink
Merge pull request #15 from kellyelton/patch-1
Browse files Browse the repository at this point in the history
Couple mistakes, like event delegate being registered in the wrong spot,...
  • Loading branch information
alanmcgovern committed Jun 12, 2012
2 parents ea8e3dc + 06fc438 commit 36d3b44
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions src/DhtSampleClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.