Search in sources :

Example 1 with ObjectSet

use of com.badlogic.gdx.utils.ObjectSet in project Mindustry by Anuken.

the class KryoClient method discover.

@Override
public void discover(Consumer<Array<Host>> callback) {
    runAsync(() -> {
        addresses.clear();
        List<InetAddress> list = client.discoverHosts(port, 3000);
        ObjectSet<String> hostnames = new ObjectSet<>();
        Array<Host> result = new Array<>();
        for (InetAddress a : list) {
            if (!hostnames.contains(a.getHostName())) {
                Host address = addresses.get(a);
                if (address != null)
                    result.add(address);
            }
            hostnames.add(a.getHostName());
        }
        Gdx.app.postRunnable(() -> callback.accept(result));
    });
}
Also used : Array(com.badlogic.gdx.utils.Array) Host(io.anuke.mindustry.net.Host) ObjectSet(com.badlogic.gdx.utils.ObjectSet) InetAddress(java.net.InetAddress)

Aggregations

Array (com.badlogic.gdx.utils.Array)1 ObjectSet (com.badlogic.gdx.utils.ObjectSet)1 Host (io.anuke.mindustry.net.Host)1 InetAddress (java.net.InetAddress)1