feat: WebSocket-Integration mit UI-Reaktivierung für GisStationsStaticDistrict
- WebSocket-Trigger implementiert, der `fetchGisStationsStaticDistrictThunk` ausführt. - Trigger-Mechanismus über `useState` (`triggerUpdate`) sorgt für gezielten UI-Re-Render. - Problem gelöst, dass Redux-Store zwar neue Daten enthielt, aber die UI nicht aktualisiert wurde. - MapComponent.js und useDynamicDeviceLayers.js entsprechend angepasst.
This commit is contained in:
20
server.js
20
server.js
@@ -35,7 +35,6 @@ app.prepare().then(() => {
|
||||
|
||||
io.on("connection", socket => {
|
||||
const { m: idMap, u: idUser, mode } = socket.handshake.query;
|
||||
const isLiveMode = mode === "live";
|
||||
console.log(`🔌 WebSocket verbunden (idMap=${idMap}, idUser=${idUser}, mode=${mode})`);
|
||||
|
||||
const endpoints = [
|
||||
@@ -80,7 +79,7 @@ app.prepare().then(() => {
|
||||
const jsonStr = fs.readFileSync(mockPath, "utf-8");
|
||||
const json = JSON.parse(jsonStr);
|
||||
statis = extractData(json, name);
|
||||
console.log(`🧪 [Mock] ${name}`);
|
||||
//console.log(`🧪 [Mock] ${name}`);
|
||||
} else {
|
||||
const fetchUrl = `http://localhost/talas5/ClientData/${getUrl()}`;
|
||||
const res = await fetch(fetchUrl);
|
||||
@@ -106,7 +105,7 @@ app.prepare().then(() => {
|
||||
console.log(`✅ Änderung bei ${name} erkannt → gesendet`);
|
||||
writeJsonFile(`${name}.json`, statis);
|
||||
} else {
|
||||
console.log(`🔁 ${name}: Keine Änderung`);
|
||||
// console.log(`🔁 ${name}: Keine Änderung`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ Fehler bei ${name}:`, error.message);
|
||||
@@ -114,14 +113,13 @@ app.prepare().then(() => {
|
||||
}
|
||||
};
|
||||
|
||||
if (isLiveMode) {
|
||||
fetchData();
|
||||
const interval = setInterval(fetchData, 5000);
|
||||
socket.on("disconnect", () => {
|
||||
clearInterval(interval);
|
||||
console.log("❌ WebSocket getrennt");
|
||||
});
|
||||
}
|
||||
// fetchData immer ausführen – unabhängig vom Modus
|
||||
fetchData();
|
||||
const interval = setInterval(fetchData, 5000);
|
||||
socket.on("disconnect", () => {
|
||||
clearInterval(interval);
|
||||
console.log("❌ WebSocket getrennt");
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
|
||||
Reference in New Issue
Block a user