31 lines
827 B
HTML
31 lines
827 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Ping Demo</title>
|
|
<script>
|
|
const ws = new WebSocket("wss://localhost:8443/ws");
|
|
|
|
ws.onopen = () => console.log("Connected")
|
|
ws.onmessage = (event) => console.log(event.data)
|
|
ws.onclose = () => console.log("Closed")
|
|
|
|
setInterval(() => {
|
|
if (ws.readyState === WebSocket.OPEN) {
|
|
const message = {
|
|
type: "ping",
|
|
timestamp: Date(),
|
|
random: Math.random()
|
|
};
|
|
|
|
ws.send(JSON.stringify(message))
|
|
}
|
|
}, 1000)
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>Hello, {{.Name}}!</h1>
|
|
<p>This page sends a ping to the server every second.</p>
|
|
</body>
|
|
</html>
|