use of org.lanternpowered.server.network.pipeline.LegacyProtocolHandler in project LanternServer by LanternPowered.
the class NetworkManager method init0.
@Override
protected ChannelFuture init0(SocketAddress address, boolean epoll) {
this.bootstrap = new ServerBootstrap();
// Take advantage of the fast thread local threads,
// this is also provided by the default thread factory
final ThreadFactory threadFactory = ThreadHelper.newFastThreadLocalThreadFactory(() -> "netty-" + threadCounter.getAndIncrement());
this.bossGroup = createEventLoopGroup(epoll, threadFactory);
this.workerGroup = createEventLoopGroup(epoll, threadFactory);
this.socketAddress = address;
return this.bootstrap.group(this.bossGroup, this.workerGroup).channel(getServerSocketChannelClass(epoll)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
final NetworkSession networkSession = new NetworkSession(ch, server, NetworkManager.this);
final CodecContext codecContext = new SimpleCodecContext(new LanternByteBufferAllocator(ch.alloc()), ch, networkSession);
pipeline.addLast(new ReadTimeoutHandler(NetworkSession.READ_TIMEOUT_SECONDS)).addLast(NetworkSession.LEGACY_PING, new LegacyProtocolHandler(networkSession)).addLast(NetworkSession.ENCRYPTION, NoopHandler.INSTANCE).addLast(NetworkSession.FRAMING, new MessageFramingHandler()).addLast(NetworkSession.COMPRESSION, NoopHandler.INSTANCE).addLast(NetworkSession.CODECS, new MessageCodecHandler(codecContext)).addLast(NetworkSession.PROCESSOR, new MessageProcessorHandler(codecContext)).addLast(NetworkSession.HANDLER, networkSession);
}
}).childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).childOption(ChannelOption.TCP_NODELAY, true).childOption(ChannelOption.SO_KEEPALIVE, true).bind(address);
}
Aggregations