-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-client.html
More file actions
44 lines (38 loc) · 1.13 KB
/
test-client.html
File metadata and controls
44 lines (38 loc) · 1.13 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
<!DOCTYPE html>
<html>
<head>
<title>WebSocket Test Client</title>
<script src="https://cdn.socket.io/4.0.1/socket.io.min.js"></script>
</head>
<body>
<h1>WebSocket Test</h1>
<button onclick="sendMessage()">Send Message</button>
<button onclick="sendPing()">Send Ping</button>
<script>
const socket = io("wss://demo.avideo.com:20532");
socket.on("connect", () => {
console.log("Connected to WebSocket server");
});
socket.on("chatMessage", (data) => {
console.log("Received chat message:", data);
});
socket.on("pong", (data) => {
console.log("Received pong:", data);
});
function sendMessage() {
socket.emit("message", JSON.stringify({
type: "chat",
text: "Hello from client!"
}));
}
function sendPing() {
socket.emit("message", JSON.stringify({
type: "ping"
}));
}
socket.on("disconnect", () => {
console.log("Disconnected from WebSocket server");
});
</script>
</body>
</html>