diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java index 4c0dcb9d..a681e70c 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java @@ -35,14 +35,14 @@ public enum SourceOperateCodeEnum { QUIT_INIT_03("QUIT_FUNEND$03", "关闭暂态申请"), - - + /** + * 请求操作类型对应实体中 requestId + */ YJC_YTXJY("yjc_ytxjy", "预检测_源通讯检测"), YJC_SBTXJY("yjc_sbtxjy", "预检测_设备通讯检测"), YJC_XYJY("yjc_xyjy", "预检测_协议校验"), YJC_XUJY("YJC_xujy", "预检测_相序校验"), - QUITE("quit","预监测_关闭设备通讯初始化"), QUITE_SOURCE("close_source","预监测_关闭源通讯") diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java index 8ccf18e4..d53473c0 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java @@ -41,39 +41,39 @@ public class WebSocketService { @PostConstruct public void start() { -// new Thread(() -> { -// //可以自定义线程的数量 -// bossGroup = new NioEventLoopGroup(); -// // 默认创建的线程数量 = CPU 处理器数量 *2 -// workerGroup = new NioEventLoopGroup(); -// try { -// ServerBootstrap serverBootstrap = new ServerBootstrap(); -// serverBootstrap.group(bossGroup, workerGroup) -// .channel(NioServerSocketChannel.class) -// .handler(new LoggingHandler()) -// //当前连接被阻塞的时候,BACKLOG代表的事 阻塞队列的长度 -// .option(ChannelOption.SO_BACKLOG, 128) -// .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) -// -// //设置连接保持为活动状态 -// .childOption(ChannelOption.SO_KEEPALIVE, true) -// .childHandler(webSocketInitializer); -// ChannelFuture future = serverBootstrap.bind(port).sync(); -// future.addListener(f -> { -// if (future.isSuccess()) { -// System.out.println("webSocket服务启动成功"); -// } else { -// System.out.println("webSocket服务启动失败"); -// } -// }); -// future.channel().closeFuture().sync(); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } finally { -// bossGroup.shutdownGracefully(); -// workerGroup.shutdownGracefully(); -// } -// }).start(); + new Thread(() -> { + //可以自定义线程的数量 + bossGroup = new NioEventLoopGroup(); + // 默认创建的线程数量 = CPU 处理器数量 *2 + workerGroup = new NioEventLoopGroup(); + try { + ServerBootstrap serverBootstrap = new ServerBootstrap(); + serverBootstrap.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .handler(new LoggingHandler()) + //当前连接被阻塞的时候,BACKLOG代表的事 阻塞队列的长度 + .option(ChannelOption.SO_BACKLOG, 128) + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) + + //设置连接保持为活动状态 + .childOption(ChannelOption.SO_KEEPALIVE, true) + .childHandler(webSocketInitializer); + ChannelFuture future = serverBootstrap.bind(port).sync(); + future.addListener(f -> { + if (future.isSuccess()) { + System.out.println("webSocket服务启动成功"); + } else { + System.out.println("webSocket服务启动失败"); + } + }); + future.channel().closeFuture().sync(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } + }).start(); }