Search in sources :

Example 1 with ProtocolProvider

use of net.glowstone.net.protocol.ProtocolProvider in project Glowstone by GlowstoneMC.

the class GlowServer method bind.

private void bind() {
    if (Networking.EPOLL_AVAILABLE) {
        ConsoleMessages.Info.NativeTransport.EPOLL.log();
    } else if (Networking.KQUEUE_AVAILABLE) {
        ConsoleMessages.Info.NativeTransport.KQUEUE.log();
    }
    CountDownLatch latch = new CountDownLatch(3);
    ProtocolProvider protocolProvider = new ProtocolProvider(config);
    networkServer = new GameServer(this, protocolProvider, latch);
    networkServer.bind(getBindAddress(Key.SERVER_PORT));
    if (config.getBoolean(Key.QUERY_ENABLED)) {
        queryServer = new QueryServer(this, protocolProvider, 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, protocolProvider, latch, config.getString(Key.RCON_PASSWORD));
        rconServer.bind(getBindAddress(Key.RCON_PORT));
    } else {
        latch.countDown();
    }
    try {
        latch.await();
    } catch (InterruptedException e) {
        ConsoleMessages.Error.Rcon.BIND_INTERRUPTED.log(e);
        System.exit(1);
    }
}
Also used : QueryServer(net.glowstone.net.query.QueryServer) RconServer(net.glowstone.net.rcon.RconServer) ProtocolProvider(net.glowstone.net.protocol.ProtocolProvider) CountDownLatch(java.util.concurrent.CountDownLatch) GameServer(net.glowstone.net.GameServer)

Example 2 with ProtocolProvider

use of net.glowstone.net.protocol.ProtocolProvider in project Glowstone by GlowstoneMC.

the class HandshakeProtocolTest method createHandshakeProtocol.

private static HandshakeProtocol createHandshakeProtocol() {
    ServerConfig serverConfig = mock(ServerConfig.class);
    when(serverConfig.getMapList(ServerConfig.Key.DNS_OVERRIDES)).thenReturn(Collections.emptyList());
    ProtocolProvider protocolProvider = new ProtocolProvider(serverConfig);
    return protocolProvider.handshake;
}
Also used : ServerConfig(net.glowstone.util.config.ServerConfig) ProtocolProvider(net.glowstone.net.protocol.ProtocolProvider)

Example 3 with ProtocolProvider

use of net.glowstone.net.protocol.ProtocolProvider in project Glowstone by GlowstoneMC.

the class GameServerTest method setUp.

@BeforeEach
public void setUp() throws IllegalAccessException {
    GlowServer.logger.addHandler(handler);
    glowServer = mock(GlowServer.class, Answers.RETURNS_SMART_NULLS);
    CountDownLatch latch = new CountDownLatch(1);
    ProtocolProvider protocolProvider = new ProtocolProvider(mock(HandshakeProtocol.class), mock(StatusProtocol.class), mock(LoginProtocol.class), mock(PlayProtocol.class));
    gameServer = new GameServer(glowServer, protocolProvider, latch);
    latch.countDown();
}
Also used : StatusProtocol(net.glowstone.net.protocol.StatusProtocol) HandshakeProtocol(net.glowstone.net.protocol.HandshakeProtocol) ProtocolProvider(net.glowstone.net.protocol.ProtocolProvider) GlowServer(net.glowstone.GlowServer) CountDownLatch(java.util.concurrent.CountDownLatch) PlayProtocol(net.glowstone.net.protocol.PlayProtocol) LoginProtocol(net.glowstone.net.protocol.LoginProtocol) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ProtocolProvider

use of net.glowstone.net.protocol.ProtocolProvider 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);
    ProtocolProvider protocolProvider = new ProtocolProvider(mock(HandshakeProtocol.class), mock(StatusProtocol.class), mock(LoginProtocol.class), mock(PlayProtocol.class));
    this.queryPlugins = true;
    server = new QueryServer(glowServer, protocolProvider, latch, queryPlugins);
    random = mock(ThreadLocalRandom.class);
    PowerMockito.mockStatic(ThreadLocalRandom.class);
    when(ThreadLocalRandom.current()).thenReturn(random);
    address = InetSocketAddress.createUnresolved("somehost", 12345);
}
Also used : StatusProtocol(net.glowstone.net.protocol.StatusProtocol) HandshakeProtocol(net.glowstone.net.protocol.HandshakeProtocol) QueryServer(net.glowstone.net.query.QueryServer) ProtocolProvider(net.glowstone.net.protocol.ProtocolProvider) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) GlowServer(net.glowstone.GlowServer) CountDownLatch(java.util.concurrent.CountDownLatch) PlayProtocol(net.glowstone.net.protocol.PlayProtocol) LoginProtocol(net.glowstone.net.protocol.LoginProtocol) Before(org.junit.Before)

Example 5 with ProtocolProvider

use of net.glowstone.net.protocol.ProtocolProvider in project Glowstone by GlowstoneMC.

the class LoginProtocolTest method createLoginProtocol.

private static LoginProtocol createLoginProtocol() {
    ServerConfig serverConfig = mock(ServerConfig.class);
    when(serverConfig.getMapList(ServerConfig.Key.DNS_OVERRIDES)).thenReturn(Collections.emptyList());
    ProtocolProvider protocolProvider = new ProtocolProvider(serverConfig);
    return protocolProvider.login;
}
Also used : ServerConfig(net.glowstone.util.config.ServerConfig) ProtocolProvider(net.glowstone.net.protocol.ProtocolProvider)

Aggregations

ProtocolProvider (net.glowstone.net.protocol.ProtocolProvider)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 GlowServer (net.glowstone.GlowServer)2 HandshakeProtocol (net.glowstone.net.protocol.HandshakeProtocol)2 LoginProtocol (net.glowstone.net.protocol.LoginProtocol)2 PlayProtocol (net.glowstone.net.protocol.PlayProtocol)2 StatusProtocol (net.glowstone.net.protocol.StatusProtocol)2 QueryServer (net.glowstone.net.query.QueryServer)2 ServerConfig (net.glowstone.util.config.ServerConfig)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 GameServer (net.glowstone.net.GameServer)1 RconServer (net.glowstone.net.rcon.RconServer)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1