forked from jyh7a/socket_emit_send_diff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.html
38 lines (33 loc) · 944 Bytes
/
index2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.socket.io/socket.io-3.0.1.min.js"></script>
<title>클라이언트_2</title>
</head>
<body>
<h1>클라이언트_2</h1>
<div>
<h2>message로 받은 내용</h2>
<p class="message_content"></p>
</div>
<br />
<div>
<h2>client_2로 받은 내용</h2>
<p class="client_2_conent"></p>
</div>
<script>
const socket = io("ws://localhost:3000");
socket.on("connect", () => {
socket.send("client_2 접속~!");
});
socket.on("message", (data) => {
document.querySelector(".message_content").textContent = data;
});
socket.on("client_2", (data) => {
document.querySelector(".client_2_conent").textContent = data;
});
</script>
</body>
</html>