From e766f4313a7de49f701bc894b881371452148f9b Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Fri, 29 Jan 2021 21:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90notice/message=E3=80=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=B3=A8=E9=87=8Awebsocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhanqing <447067298@qq.com> --- src/main/webapp/pages/index.html | 38 +------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/src/main/webapp/pages/index.html b/src/main/webapp/pages/index.html index 67051511..d123f4f1 100644 --- a/src/main/webapp/pages/index.html +++ b/src/main/webapp/pages/index.html @@ -107,7 +107,7 @@ request.start(); }); wsInst = ws.render({ - wsUrl: Feng.wsUrl,//WebSocket的地址 + wsUrl: Feng.wsUrl, //WebSocket的地址 connectErr: function (event) { console.log(event) //如果不支持websocket 回调 @@ -145,42 +145,6 @@ }) }); - /* - var socket; - if (typeof (WebSocket) == "undefined") { - console.log("遗憾:您的浏览器不支持WebSocket"); - } else { - - //实现化WebSocket对象 - //指定要连接的服务器地址与端口建立连接 - //注意ws、wss使用不同的端口。我使用自签名的证书测试, - //无法使用wss,浏览器打开WebSocket时报错 - //ws对应http、wss对应https。 - socket = new WebSocket(Feng.wsUrl); - //连接打开事件 - socket.onopen = function() { - console.log("Socket 已打开"); - socket.send("消息发送测试(From Client)"); - }; - //收到消息事件 - socket.onmessage = function(msg) { - console.log(msg.data); - }; - //连接关闭事件 - socket.onclose = function() { - console.log("Socket已关闭"); - }; - //发生了错误事件 - socket.onerror = function() { - alert("Socket发生了错误"); - } - - //窗口关闭时,关闭连接 - window.unload=function() { - socket.close(); - }; - - }*/ window.unload = function () { if (wsInst) { wsInst.close();