Skip to content

Commit

Permalink
refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Junze888 committed Jun 30, 2024
1 parent c07a281 commit 0378ac7
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/main/java/io/xdag/net/websocket/WebSocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,18 +48,8 @@ public class WebSocketServer {
private final PoolHandShakeHandler poolHandShakeHandler;

public WebSocketServer(Kernel kernel, List<String> 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)
Expand Down

0 comments on commit 0378ac7

Please sign in to comment.