From c42614978ff12013a1eabebd0289b27169a5784f Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 06 五月 2025 17:25:56 +0800 Subject: [PATCH] 1、实现万功能token(0000-0000-1234-9876-5); 2、web端单独实现命令结果等待器,并相应修改相关部分; 3、web端实现透传命令; 4、修改一些不当注释; 5、优化一些代码。 --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketServer.java | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketServer.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketServer.java index 423b4e8..f2c0041 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketServer.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketServer.java @@ -1,6 +1,7 @@ package com.dy.pipIrrRemote.largeScreen; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import jakarta.websocket.*; @@ -13,10 +14,13 @@ * @Author: liurunyu * @Date: 2025/2/10 15:25 * @Description 瀹㈡埛绔紙娴忚鍣級姣忓缓绔嬩竴涓獁ebsocket杩炴帴锛屾湇鍔$灏变細鍒涘缓涓�涓猈ebSocketServer瀹炰緥 + * 搴旂敤鍓嶆彁鏄瓨鍦ㄤ竴涓狢onfig绫伙紝濡傛湰妯″潡鐨刉ebSocketConfig锛岃繖鏃禓ServerEndpoint鍙桽pringBoot瀹瑰櫒 + * 绠$悊浜嗭紙鍦ㄥ祵鍏ュ紡web Servlet鐜涓級 */ @Slf4j @ServerEndpoint("/websocket/ls/{id}") @Component +@Scope("prototype") // 闈炲崟渚嬶紝姣忔璇锋眰閮戒細鍒涘缓鏂扮殑瀹炰緥 public class WebSocketServer { // 闈欐�佸彉閲忥紝璁板綍褰撳墠鍦ㄧ嚎杩炴帴鏁� @@ -27,7 +31,8 @@ // 瀹㈡埛绔繛鎺ヤ細璇濓紝閫氳繃瀹冪粰瀹㈡埛绔彂閫佹暟鎹� private Session session; - + // 瀹㈡埛绔笂绾挎椂鍒� + //private String onLineDt ; // 瀹㈡埛绔痠d private String id = ""; @@ -39,6 +44,7 @@ @OnOpen public void onOpen(Session session, @PathParam("id") String id) { this.session = session; + //this.onLineDt = DateTime.yyyy_MM_dd_HH_mm_ss() ; this.id = id; if(this.id == null || this.id.length() == 0){ this.id = "" + System.nanoTime() ; @@ -101,7 +107,7 @@ /** * 鏈嶅姟鍣ㄤ富鍔ㄧ兢鎺ㄩ�佹秷鎭� */ - public static void sendAllMessage(String message) throws IOException { + public static void sendMessage2AllClient(String message) throws IOException { ConcurrentHashMap.KeySetView<String, WebSocketServer> ids = webSocketMap.keySet(); for (String id : ids) { WebSocketServer webSocketServer = webSocketMap.get(id); @@ -112,7 +118,7 @@ /** * 鏈嶅姟鍣ㄦ寚瀹氬鎴风鎺ㄩ�佹秷鎭� */ - public static void sendOneMessage(String message, String id) throws IOException { + public static void sendMessage2OneClient(String message, String id) throws IOException { if (message != null && message.length() != 0 && webSocketMap.containsKey(id)) { webSocketMap.get(id).sendMessage(message); } else { -- Gitblit v1.8.0