ws webSocket test
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user