Search in sources :

Example 1 with QueryServer

use of net.glowstone.net.query.QueryServer in project Glowstone by GlowstoneMC.

the class GlowServer method bind.

private void bind() {
    if (Epoll.isAvailable()) {
        logger.info("Native epoll transport is enabled.");
    }
    CountDownLatch latch = new CountDownLatch(3);
    networkServer = new GameServer(this, latch);
    networkServer.bind(getBindAddress(Key.SERVER_PORT));
    if (config.getBoolean(Key.QUERY_ENABLED)) {
        queryServer = new QueryServer(this, latch, config.getBoolean(Key.QUERY_PLUGINS));
        queryServer.bind(getBindAddress(Key.QUERY_PORT));
    } else {
        latch.countDown();
    }
    if (config.getBoolean(Key.RCON_ENABLED)) {
        rconServer = new RconServer(this, latch, config.getString(Key.RCON_PASSWORD));
        rconServer.bind(getBindAddress(Key.RCON_PORT));
    } else {
        latch.countDown();
    }
    try {
        latch.await();
    } catch (InterruptedException e) {
        logger.log(Level.SEVERE, "Bind interrupted! ", e);
        System.exit(1);
    }
}
Also used : QueryServer(net.glowstone.net.query.QueryServer) RconServer(net.glowstone.net.rcon.RconServer) CountDownLatch(java.util.concurrent.CountDownLatch) GameServer(net.glowstone.net.GameServer)

Example 2 with QueryServer

use of net.glowstone.net.query.QueryServer in project Glowstone by GlowstoneMC.

the class QueryTest method setup.

@Before
public void setup() throws Exception {
    glowServer = mock(GlowServer.class);
    CountDownLatch latch = new CountDownLatch(1);
    this.queryPlugins = true;
    server = new QueryServer(glowServer, latch, queryPlugins);
    random = mock(ThreadLocalRandom.class);
    PowerMockito.mockStatic(ThreadLocalRandom.class);
    when(ThreadLocalRandom.current()).thenReturn(random);
    address = InetSocketAddress.createUnresolved("somehost", 12345);
}
Also used : QueryServer(net.glowstone.net.query.QueryServer) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) GlowServer(net.glowstone.GlowServer) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)2 QueryServer (net.glowstone.net.query.QueryServer)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 GlowServer (net.glowstone.GlowServer)1 GameServer (net.glowstone.net.GameServer)1 RconServer (net.glowstone.net.rcon.RconServer)1 Before (org.junit.Before)1