JXTA - Internet

0 respostas
heatcold

Estou tentando buscar o advertisement de um peer rendezvouz especificado no NetworkConfigurator mas não tenho retorno.
Alguem sabe me dizer o que está errado?

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import net.jxta.discovery.DiscoveryEvent;
import net.jxta.discovery.DiscoveryListener;
import net.jxta.discovery.DiscoveryService;
import net.jxta.exception.PeerGroupException;
import net.jxta.peergroup.PeerGroup;
import net.jxta.platform.NetworkConfigurator;
import net.jxta.platform.NetworkManager;

public class Discovery implements DiscoveryListener {

    public void run() throws URISyntaxException, PeerGroupException, IOException
    {
        NetworkManager manager = new NetworkManager(NetworkManager.ConfigMode.ADHOC, "EchoServer",
                new File(new File(".cache"), "EchoServer").toURI());

        NetworkConfigurator config = manager.getConfigurator();

        config.setTcpEnabled(true);
        config.setTcpIncoming(true);
        config.setTcpOutgoing(true);

        config.setHttpEnabled(true);
        config.setHttpIncoming(true);
        config.setHttpOutgoing(true);

        config.addRdvSeedingURI(new URI("http://192.18.37.36:9700"));
        config.addRelaySeedingURI(new URI("tcp://192.18.37.36:9701"));

        config.save();

        manager.startNetwork();

        PeerGroup netPeerGroup = manager.getNetPeerGroup();

        DiscoveryService discovery = netPeerGroup.getDiscoveryService();

        discovery.addDiscoveryListener(this);

        discovery.getRemoteAdvertisements(null, 2, null,
            netPeerGroup.getPeerGroupID().toString(),
            0, this);

        try {
            Thread.sleep(5000);
        } catch (InterruptedException interruptedException) {
            interruptedException.printStackTrace();
        }

        manager.stopNetwork();
        System.exit(0);
    }

    public static void main(String[] args) throws IOException, URISyntaxException, PeerGroupException {
        
        new Discovery().run();
    }

    public void discoveryEvent(DiscoveryEvent arg0) {
        System.out.println("here");
    }
}
Criado 29 de agosto de 2008
Respostas 0
Participantes 1