mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-11-02 19:21:51 +08:00
refactor: replace NioEventLoopGroup with MultiThreadIoEventLoopGroup to utilize NioIoHandler factory in UDP and TCP Netty servers
This commit is contained in:
+3
-6
@@ -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)
|
||||
|
||||
+3
-6
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user