mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-31 20:41:29 +01:00
TCP_NODELAY
This commit is contained in:
parent
6a6309377f
commit
f8dceb51b4
@ -17,8 +17,6 @@ import java.net.InetSocketAddress;
|
|||||||
|
|
||||||
public class NettyServer {
|
public class NettyServer {
|
||||||
|
|
||||||
private final PacketProcessor packetProcessor;
|
|
||||||
|
|
||||||
private final EventLoopGroup boss, worker;
|
private final EventLoopGroup boss, worker;
|
||||||
private final ServerBootstrap bootstrap;
|
private final ServerBootstrap bootstrap;
|
||||||
|
|
||||||
@ -28,8 +26,6 @@ public class NettyServer {
|
|||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
public NettyServer(PacketProcessor packetProcessor) {
|
public NettyServer(PacketProcessor packetProcessor) {
|
||||||
this.packetProcessor = packetProcessor;
|
|
||||||
|
|
||||||
Class<? extends ServerChannel> channel;
|
Class<? extends ServerChannel> channel;
|
||||||
|
|
||||||
if (Epoll.isAvailable()) {
|
if (Epoll.isAvailable()) {
|
||||||
@ -49,12 +45,15 @@ public class NettyServer {
|
|||||||
bootstrap.channel(channel);
|
bootstrap.channel(channel);
|
||||||
|
|
||||||
bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
|
bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||||
protected void initChannel(SocketChannel socketChannel) {
|
protected void initChannel(SocketChannel ch) {
|
||||||
socketChannel.pipeline().addLast(new NettyDecoder());
|
ChannelConfig config = ch.config();
|
||||||
socketChannel.pipeline().addLast(new ClientChannel(packetProcessor));
|
config.setOption(ChannelOption.TCP_NODELAY, true);
|
||||||
|
|
||||||
|
ChannelPipeline pipeline = ch.pipeline();
|
||||||
|
pipeline.addLast(new NettyDecoder());
|
||||||
|
pipeline.addLast(new ClientChannel(packetProcessor));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(String address, int port) {
|
public void start(String address, int port) {
|
||||||
|
Loading…
Reference in New Issue
Block a user