Update all files
This commit is contained in:
40
test_websocket.html
Normal file
40
test_websocket.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>WebSocket Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>WebSocket Test</h1>
|
||||
<p id="status">Connecting...</p>
|
||||
<script>
|
||||
const versionId = "625b4a46-bb84-44c5-bfce-13f62b2b4dcf"; // Use the same ID from the error
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/versions/${versionId}`);
|
||||
|
||||
ws.onopen = () => {
|
||||
document.getElementById("status").textContent = "Connected!";
|
||||
document.getElementById("status").style.color = "green";
|
||||
|
||||
// Send a ping
|
||||
ws.send(JSON.stringify({ event: "ping" }));
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
console.log("Message received:", event.data);
|
||||
const data = JSON.parse(event.data);
|
||||
if (data.event === "pong") {
|
||||
document.getElementById("status").textContent += " Pong received!";
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = (error) => {
|
||||
document.getElementById("status").textContent = "Error: " + error.message;
|
||||
document.getElementById("status").style.color = "red";
|
||||
console.error("WebSocket error:", error);
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
document.getElementById("status").textContent += " Connection closed";
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user