}
public void discover(final boolean first) {
displayMessage("Discovering GeForce PCs...");
final Object mutex = new Object();
MdnsDiscoveryAgent agent = new MdnsDiscoveryAgent(new MdnsDiscoveryListener() {
@Override
public void notifyComputerAdded(MdnsComputer computer) {
displayMessage(" " + computer.getName() + " " + computer.getAddress().getHostAddress());
host = computer.getAddress();
if (first)
synchronized (mutex) {
mutex.notify();
}
}
@Override
public void notifyComputerRemoved(MdnsComputer computer) {
}
@Override
public void notifyDiscoveryFailure(Exception e) {
}
});
agent.startDiscovery(1000);
synchronized (mutex) {
try {
mutex.wait();
} catch (InterruptedException ex) { }
}
agent.stopDiscovery();
}