Skip to content

Commit

Permalink
Working DhtTest test.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 26, 2015
1 parent c8d3e7e commit 988e634
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/com/frostwire/jlibtorrent/demo/DhtTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.frostwire.jlibtorrent.demo;

import com.frostwire.jlibtorrent.*;
import com.frostwire.jlibtorrent.AlertListener;
import com.frostwire.jlibtorrent.DHT;
import com.frostwire.jlibtorrent.Session;
import com.frostwire.jlibtorrent.TcpEndpoint;
import com.frostwire.jlibtorrent.alerts.Alert;
import com.frostwire.jlibtorrent.alerts.DhtBootstrapAlert;
import com.frostwire.jlibtorrent.alerts.DhtGetPeersReplyAlert;
import com.frostwire.jlibtorrent.alerts.ExternalIpAlert;

import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
* @author gubatron
Expand All @@ -33,7 +37,7 @@ public int[] types() {

@Override
public void alert(Alert<?> alert) {
//System.out.println(alert);
System.out.println(alert);

if (alert instanceof DhtBootstrapAlert) {
signal.countDown();
Expand All @@ -57,22 +61,22 @@ public void alert(Alert<?> alert) {

System.out.println("Waiting to DHT bootstrap");

signal.await();
signal.await(10, TimeUnit.SECONDS);

//System.out.println("Calling dht_get_peers");
System.out.println("Calling dht_get_peers");

//dht.getPeers("86d0502ead28e495c9e67665340f72aa72fe304");
dht.getPeers("86d0502ead28e495c9e67665340f72aa72fe304");

Thread.sleep(4000);
dht.waitNodes(1);

//dht.announce("47d0502ead28e495c9e67665340f72aa72fe304", 9999, 0);
dht.announce("47d0502ead28e495c9e67665340f72aa72fe304", 9999, 0);

//System.out.println("Waiting 15 seconds");
//Thread.sleep(15000);
System.out.println("Waiting 15 seconds");
Thread.sleep(15000);

dht.getPeers("5472d2fe734c16f28912e1e756b57e2470148b93");
//dht.getPeers("47d0502ead28e495c9e67665340f72aa72fe304");
//dht.getPeers("5472d2fe734c16f28912e1e756b57e2470148b93");
dht.getPeers("47d0502ead28e495c9e67665340f72aa72fe304");

System.out.println("Press ENTER to exit");
System.in.read();
Expand Down

0 comments on commit 988e634

Please sign in to comment.