From 0378ac79f376e8fda1052ec788b746205d56c3b6 Mon Sep 17 00:00:00 2001 From: June <2571240520@qq.com> Date: Sun, 30 Jun 2024 16:22:53 +0800 Subject: [PATCH] refactor. --- .../io/xdag/net/websocket/WebSocketServer.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/xdag/net/websocket/WebSocketServer.java b/src/main/java/io/xdag/net/websocket/WebSocketServer.java index 2dd589ca..f7280719 100644 --- a/src/main/java/io/xdag/net/websocket/WebSocketServer.java +++ b/src/main/java/io/xdag/net/websocket/WebSocketServer.java @@ -25,18 +25,14 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; -import io.netty.channel.epoll.EpollEventLoopGroup; -import io.netty.channel.kqueue.KQueueEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; -import io.netty.util.NettyRuntime; import io.xdag.Kernel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.SystemUtils; import javax.annotation.Nullable; import java.util.List; @@ -52,18 +48,8 @@ public class WebSocketServer { private final PoolHandShakeHandler poolHandShakeHandler; public WebSocketServer(Kernel kernel, List poolWhiteIPList, int port) { - int workerThreadPoolSize = NettyRuntime.availableProcessors() * 2; - if(SystemUtils.IS_OS_LINUX) { - this.bossGroup = new EpollEventLoopGroup(); - this.workerGroup = new EpollEventLoopGroup(workerThreadPoolSize); - } else if(SystemUtils.IS_OS_MAC) { - this.bossGroup = new KQueueEventLoopGroup(); - this.workerGroup = new KQueueEventLoopGroup(workerThreadPoolSize); - - } else { - this.bossGroup = new NioEventLoopGroup(); - this.workerGroup = new NioEventLoopGroup(workerThreadPoolSize); - } + this.bossGroup = new NioEventLoopGroup(); + this.workerGroup = new NioEventLoopGroup(); this.poolHandShakeHandler = new PoolHandShakeHandler(kernel, poolWhiteIPList, port); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup)