From c253b555c7905c5136d47cd615ef545fa50cc6ad Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Sun, 20 Feb 2022 21:24:16 +0800 Subject: [PATCH] Merge branch 'api_score_meger' --- zq-erp/src/main/resources/static/demoPage/soketLoginTest.html | 138 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 138 insertions(+), 0 deletions(-) diff --git a/zq-erp/src/main/resources/static/demoPage/soketLoginTest.html b/zq-erp/src/main/resources/static/demoPage/soketLoginTest.html new file mode 100644 index 0000000..0598c8d --- /dev/null +++ b/zq-erp/src/main/resources/static/demoPage/soketLoginTest.html @@ -0,0 +1,138 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="utf-8"> + <!-- 启用360浏览器的极速模式(webkit) --> + <meta name="renderer" content="webkit"> + <meta name="viewport" + content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> + <title>soketTest</title> + <link th:href="@{/images/}" + rel="SHORTCUT ICON"> + <meta name="keywords" + content=""/> + <meta name="description" + content=""/> + <style type="text/css"> + .row > div:nth-child(1) { + background: url(../../images/login-title.jpg) no-repeat; + background-size: 100% 100%; + height: 380px; + } + + .row > div:nth-child(2) { + background: #fff; + height: 380px; + } + .download-bar { + margin-top: 15px; + color: #fff; + } + + .download-bar a { + color: #fff; + margin: 0 5px; + } + + .download-bar a:hover { + text-decoration: underline; + color: #fff; + } + </style> + <script> + var isoldIE = false; + if (navigator.userAgent.indexOf("MSIE") > 0) { + if (navigator.userAgent.indexOf("MSIE 6.0") > 0 + || navigator.userAgent.indexOf("MSIE 7.0") > 0 + || avigator.userAgent.indexOf("MSIE 8.0") > 0) { + isoldIE = true; + } + } + if (window.top !== window.self) { + window.top.location = window.location + } + ; + </script> + <script type="text/javascript" + th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script> + <script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script> + <link th:href="@{/css/styleOne/login.min.css}" rel="stylesheet"> + +</head> + +<body > +<h3>hello socket</h3> +<p>【sendMsg】:<div><input style="width: 700px;" id="sendMsg" name="sendMsg" type="text" value='{ "webClientId":"123", "loginQrCodeKey":"1231" "appUserId":"1010","msgType":"1","loginOperation":"1"}';></div> +<p> +</p> + + +<p>操作:<div><button onclick="openSocket()">开启socket</button></div> +<p>【操作】:<div><button onclick="sendMessage()">发送消息</button></div> +<p>【操作】:<div><button onclick="colseSocket()">关闭连接</button></div> +</body> +<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script> + <script> + + var socket; + function openSocket() { + if(typeof(WebSocket) == "undefined") { + console.log("您的浏览器不支持WebSocket"); + }else{ + console.log("您的浏览器支持WebSocket"); + //实现化WebSocket对象,指定要连接的服务器地址与端口 建立连接 + + //var socketUrl="ws://test.hive.jyymatrix.cc/webSocketServer?userId=123"; + var socketUrl="ws://192.168.0.6:8080/webSocketServer?userId=123"; + console.log(socketUrl); + if(socket!=null){ + socket.close(); + socket=null; + } + socket = new WebSocket(socketUrl); + //打开事件 + socket.onopen = function() { + console.log("websocket已打开"); + //socket.send("这是来自客户端的消息" + location.href + new Date()); + }; + //获得消息事件 + socket.onmessage = function(msg) { + console.log("获得消息:"+msg); + var serverMsg = msg.data; + console.log(serverMsg); + + }; + //关闭事件 + socket.onclose = function() { + console.log("websocket已关闭"); + }; + //发生了错误事件 + socket.onerror = function() { + console.log("websocket发生了错误"); + } + } + } + + function sendMessage() { + if(typeof(WebSocket) == "undefined") { + console.log("您的浏览器不支持WebSocket"); + }else { + // console.log("您的浏览器支持WebSocket"); + var sendMsg = document.getElementById('sendMsg').value; + //var msg = '{ "webClientId":"'+webClientId+'","appUserId":"'+appUserId+'"}'; + console.log("发送消息"+sendMsg); + socket.send(sendMsg); + + } + } + function colseSocket() { + if(typeof(WebSocket) == "undefined") { + console.log("您的浏览器不支持WebSocket"); + }else { + socket.close(); + } + } + </script> + + +</html> \ No newline at end of file -- Gitblit v1.9.1