Search in sources :

Example 1 with ServerChannelInitializer

use of de.jackwhite20.japs.server.network.initialize.ServerChannelInitializer in project JaPS by JackWhite20.

the class JaPSServer method start.

private void start() {
    if (PipelineUtils.isEpoll()) {
        LOGGER.info("Using high performance epoll event notification mechanism");
    } else {
        LOGGER.info("Using normal select/poll event notification mechanism");
    }
    bossGroup = PipelineUtils.newEventLoopGroup(1);
    workerGroup = PipelineUtils.newEventLoopGroup(workerThreads);
    try {
        ServerBootstrap serverBootstrap = new ServerBootstrap();
        serverChannel = serverBootstrap.group(bossGroup, workerGroup).channel(PipelineUtils.getServerChannel()).childHandler(new ServerChannelInitializer(this)).option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_BACKLOG, backlog).bind(new InetSocketAddress(host, port)).sync().channel();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    LOGGER.log(Level.INFO, "JaPS server started on {0}:{1}", new Object[] { host, String.valueOf(port) });
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ServerChannelInitializer(de.jackwhite20.japs.server.network.initialize.ServerChannelInitializer) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Aggregations

ServerChannelInitializer (de.jackwhite20.japs.server.network.initialize.ServerChannelInitializer)1 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 InetSocketAddress (java.net.InetSocketAddress)1