-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
86 lines (81 loc) · 3.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>PGZ SerialPort</title>
<script src="./public/js/flexible.js"></script>
<link rel="stylesheet" href="./public/css/bootstrap.min.css">
<link rel="stylesheet" href="./public/css/index.css">
</head>
<body>
<div class="body-box">
<div class="tool-bar">
<div class="select-data">
<div class="form-group">
<label for="disabledSelect">选择串口</label>
<select id="disabledSelect" class="form-control com">
</select>
</div>
<div class="form-group">
<label for="BaudRate">波特率</label>
<!-- <input type="text" class="form-control" id="BaudRate" value="9600"> -->
<select id="baudSelect" class="form-control baud">
</select>
</div>
<div class="form-group">
<label for="debugCode">debugCode</label>
<input type="text" class="form-control" id="debugCode" value="">
</div>
</div>
</div>
<div class="content-box">
<div class="receive-box">
<div class="send-header">
<label>接受信息</label>
</div>
<div class="receive-windows">
</div>
<div id="error"></div>
<div id="ports"></div>
</div>
<div class="send-box">
<!-- <div class="send-header">
<label>发送信息</label>
</div>
<div class="send-windows">
<textarea class="input-send-data"></textarea>
</div> -->
<div class="send-btn">
<div class="btn-box">
<div class="btn btn-warning btn-send">读取卡号</div>   
<div class="btn btn-danger btn-reset">清空信息</div>
<div class="btn btn-danger btn-reset" id="debugCodeBtn">DEBUG_CODE</div>
</div>
</div>
</div>
</div>
</div>
<script src="./index.out.js" charset="utf-8"></script>
</body>
<script type="module">
const { WebSocketServer } = require('ws')
window.clients = []; // 已连接的客户端
const wss = new WebSocketServer({ port: 9526 });
wss.on('connection', function connection(ws) {
console.log('client connected',ws)
if (clients.indexOf(ws) === -1) {
clients.push(ws)
}
ws.on('message', function message(data) {
console.log('wss received: %s', data);
});
for (let c of clients) {
// 发送给其它客户端
// if (c != ws) c.send(msg);
}
ws.send('something')
});
</script>
</html>