Files
charge-pile-serve/view/Test.php

39 lines
844 B
PHP
Raw Normal View History

2025-11-10 16:12:07 +08:00
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
<script>
let ws = new WebSocket("ws://127.0.0.1:2346")
ws.onopen = function() {
console.log("连接成功");
//每30秒发送一次心跳
setInterval(function(){
ws.send(JSON.stringify({'type':"peng"}));
console.log('发送心跳...');
},30000)
};
ws.onmessage = function(evt) {
data = JSON.parse(evt.data)
console.log(data);
};
ws.onclose = function(evt) {
console.log("连接已关闭");
};
</script>
</html>