ws webSocket test

This commit is contained in:
Ismail Ali
2025-06-06 21:33:54 +02:00
parent b6a946660a
commit 368f1ae095
6 changed files with 561 additions and 86 deletions

View File

@@ -794,6 +794,18 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
return () => clearInterval(interval);
}, []);
//--------------------------------------------
const socket = new WebSocket("ws://localhost:3000");
socket.addEventListener("open", () => {
console.log("🟢 WebSocket verbunden");
socket.send(JSON.stringify({ event: "ping", page: window.location.pathname }));
});
socket.addEventListener("message", event => {
console.log("📨 Nachricht vom Server (Text):", event.data); // kein JSON.parse
});
//---------------------------------------------
//--------------------------------------------
return (