From b3927c894a7b0c243b2be0352a8fa7162533f05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E8=88=AA?= <653809315@qq.com> Date: Mon, 8 Jan 2024 16:43:02 +0800 Subject: [PATCH] =?UTF-8?q?websocket=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/radarStatus/radarStatus.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html b/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html index 97ca476..268f64d 100644 --- a/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html +++ b/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html @@ -96,7 +96,22 @@ }; $.table.init(options); }); - + + var socket = new WebSocket("ws://localhost:8080/websocket"); + + socket.onopen = function(event) { + console.log("WebSocket连接已打开"); + }; + + socket.onmessage = function(event) { + var data = event.data; + console.log("接收到数据:" + data); + // 在这里更新前端界面,显示接收到的数据 + }; + + socket.onclose = function(event) { + console.log("WebSocket连接已关闭"); + }; function customViewFormatter (data) { var template = $('#profileTemplate').html() var view = ''