socket.io und mock Data

This commit is contained in:
Ismail Ali
2025-06-07 09:12:58 +02:00
parent a55b5b0189
commit 17def7357c
4 changed files with 53 additions and 12 deletions

View File

@@ -86,7 +86,7 @@ import { io } from "socket.io-client";
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//-------------------------------
const dispatch = useDispatch();
useDataUpdater();
// useDataUpdater();
const countdown = useSelector(state => state.polylineContextMenu.countdown);
const countdownActive = useSelector(state => state.polylineContextMenu.countdownActive);
@@ -798,23 +798,31 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//--------------------------------------------
useEffect(() => {
const socket = io();
const params = new URLSearchParams(window.location.search);
const m = params.get("m");
const u = params.get("u");
const socket = io({
query: {
m,
u,
},
});
socket.on("connect", () => {
console.log("🔗 Verbunden mit dem Socket.io Server");
console.log("🔗 Socket verbunden", socket.id);
});
socket.on("message", data => {
console.log("📨 Nachricht vom Server:", data);
socket.on("gisLinesStatusUpdated", newData => {
console.log("📡 Update erhalten für m/u:", m, u);
dispatch(fetchGisLinesStatusThunk(newData));
});
socket.emit("message", { event: "ping", page: window.location.pathname });
return () => {
socket.disconnect();
console.log("🔌 Verbindung getrennt");
};
}, []);
}, [dispatch]);
//---------------------------------------------
//--------------------------------------------
return (