socket.io und mock Data
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user