| | |
| | | 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; |
| | |
| | | .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); |
| | | |