WebSocketServerProtocolHandler 服务端
WebSocketClientProtocolHandler 客户端
服务端代码
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
/**
* @author lixx
* @version 1.0
* @since 2023-05-12 15:32
*/
public class WebSocketServer {
public static void main(String[] args) throws InterruptedException {
ServerBootstrap serverBootstrap;
EventLoopGroup boss = new N