-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocketio.html
More file actions
65 lines (64 loc) · 2.22 KB
/
Copy pathsocketio.html
File metadata and controls
65 lines (64 loc) · 2.22 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>app</title>
<script
src="https://cdn.socket.io/4.3.2/socket.io.min.js"
integrity="sha384-KAZ4DtjNhLChOB/hxXuKqhMLYvx3b5MlT55xPEiNmREKRzeEm+RVPlTnAn0ajQNs"
="anonymous"
></script>
</head>
<body>
<input type="text" id="input" />
<button id="btn">send</button>
<div id="content-wrap"></div>
</body>
<script>
window.onload = () => {
let inputValue = null;
let socket = io('http://127.0.0.1:9000');
let internal = null;
socket.on('connect', () => {
console.log(
'socket connected',
new Date().toLocaleString(),
socket.id
); // x8WIv7-mJelg7on_ALbx
// internal = setInterval(()=>{
// socket.send('socket hi')
// },1000)
});
socket.on('disconnect', () => {
console.log(new Date().toLocaleString(), socket.connected); // false
console.log(
'disconnect---',
new Date().toLocaleString(),
socket.id
); // undefined
clearInterval(internal);
});
let socket2 = io('http://127.0.0.1:9000/namespace2');
let internal2 = null;
socket2.on('connect', () => {
console.log(
'socket2 connected',
new Date().toLocaleString(),
socket2.id
); // x8WIv7-mJelg7on_ALbx
// internal2 = setInterval(()=>{
// socket2.send('socket2 hi')
// },1000)
});
socket2.on('disconnect', () => {
console.log(new Date().toLocaleString(), socket2.connected); // false
console.log(
'disconnect---socket2',
new Date().toLocaleString(),
socket2.id
); // undefined
clearInterval(internal2);
});
};
</script>
</html>