//package com.ruoyi.web.core.nfid;
//
//import com.ruoyi.common.utils.spring.SpringUtils;
//import io.netty.bootstrap.ServerBootstrap;
//import io.netty.channel.*;
//import io.netty.channel.nio.NioEventLoopGroup;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.channel.socket.nio.NioServerSocketChannel;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//@Component
//public class NFIDServer {
//    private final int port = 3728;
//   // private final NFIDFrameHandler frameHandler;
//    private EventLoopGroup bossGroup;
//    private EventLoopGroup workerGroup;
//
////    @Autowired
////    private ClientHandler clientHandler;
//
////    public NFIDServer(int port) {
////        this.port = port;
////       // this.frameHandler = frameHandler;
////    }
//
//    public void start() throws Exception {
//        bossGroup = new NioEventLoopGroup(1);
//        workerGroup = new NioEventLoopGroup();
//
//        try {
//            ServerBootstrap b = new ServerBootstrap();
//            b.group(bossGroup, workerGroup)
//                    .channel(NioServerSocketChannel.class)
//                    .childHandler(new ChannelInitializer<SocketChannel>() {
//                        @Override
//                        protected void initChannel(SocketChannel ch) {
//                            ch.pipeline().addLast(new ClientHandler());
//                        }
//                    })
//                    .option(ChannelOption.SO_BACKLOG, 128)
//                    .childOption(ChannelOption.SO_KEEPALIVE, true);
//
//            ChannelFuture f = b.bind(port).sync();
//            System.out.println("NFID Server started on port " + port);
//            f.channel().closeFuture().sync();
//        } finally {
//            stop();
//        }
//    }
//
//    public void stop() {
//        if (workerGroup != null) {
//            workerGroup.shutdownGracefully();
//        }
//        if (bossGroup != null) {
//            bossGroup.shutdownGracefully();
//        }
//    }
//
//    public static void main(String[] args) throws Exception {
//        // 启动服务器
//        NFIDServer server = new NFIDServer();
//        server.start();
//    }
//}