From 01078a784d28048d5c480c7fdcdbbfdf02807a2d Mon Sep 17 00:00:00 2001 From: Vickey <891607480@qq.com> Date: Wed, 11 Feb 2026 11:58:48 +0800 Subject: [PATCH] refactor: replace `NioEventLoopGroup` with `MultiThreadIoEventLoopGroup` to utilize `NioIoHandler` factory in UDP and TCP Netty servers --- .../pnoker/driver/service/netty/tcp/NettyTcpServer.java | 9 +++------ .../pnoker/driver/service/netty/udp/NettyUdpServer.java | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/tcp/NettyTcpServer.java b/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/tcp/NettyTcpServer.java index b0c51ac71..d1ca0ccd7 100644 --- a/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/tcp/NettyTcpServer.java +++ b/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/tcp/NettyTcpServer.java @@ -18,11 +18,8 @@ package io.github.pnoker.driver.service.netty.tcp; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.*; +import io.netty.channel.nio.NioIoHandler; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.bytes.ByteArrayEncoder; @@ -64,7 +61,7 @@ public class NettyTcpServer { */ @SneakyThrows public void start(int port) { - EventLoopGroup group = new NioEventLoopGroup(); + EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory()); try { ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(group) diff --git a/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/udp/NettyUdpServer.java b/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/udp/NettyUdpServer.java index b2f20b52e..6348a0298 100644 --- a/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/udp/NettyUdpServer.java +++ b/dc3-driver/dc3-driver-listening-virtual/src/main/java/io/github/pnoker/driver/service/netty/udp/NettyUdpServer.java @@ -18,11 +18,8 @@ package io.github.pnoker.driver.service.netty.udp; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.*; +import io.netty.channel.nio.NioIoHandler; import io.netty.channel.socket.nio.NioDatagramChannel; import io.netty.handler.timeout.WriteTimeoutHandler; import lombok.SneakyThrows; @@ -51,7 +48,7 @@ public class NettyUdpServer { */ @SneakyThrows public void start(int port) { - EventLoopGroup group = new NioEventLoopGroup(); + EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory()); try { Bootstrap bootstrap = new Bootstrap(); bootstrap.group(group)