-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
29 lines (25 loc) · 731 Bytes
/
Copy pathtest.html
File metadata and controls
29 lines (25 loc) · 731 Bytes
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
<!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>Go WebSocket Tutorial</title>
</head>
<body>
<h2>Open console</h2>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
<script>
const socket = io("http://localhost:8000", {transports: ['websocket']});
socket.on('test', function (msg) {
alert(msg)
console.log(msg);
});
socket.on("test2", function (message, urgency) {
alert(message)
console.log(message + urgency);
socket.emit("ping")
})
</script>
</body>
</html>