#
whycq
2024-08-14 0d580a2b6e4ac2013ba5cbab046bdabf956b301b
app/src/main/java/com/example/agvcontroller/socket/NettyServer.java
@@ -1,5 +1,7 @@
package com.example.agvcontroller.socket;
import com.example.agvcontroller.protocol.ProtocolEncoder;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
@@ -32,9 +34,16 @@
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        public void initChannel(SocketChannel ch) throws Exception {
                            ch.pipeline().addLast(new NettyServerHandler());
                            ch.pipeline().addLast(new NettyServerHandler()).addLast(new ProtocolEncoder());
                        }
                    })
//                    .childHandler(new ChannelInitializer<Channel>(){
//
//                        @Override
//                        protected void initChannel(Channel ch) throws Exception {
//                            ch.pipeline().addLast(new ProtocolEncoder());
//                        }
//                    })
                    .option(ChannelOption.SO_BACKLOG, 128)
                    .childOption(ChannelOption.SO_KEEPALIVE, true);