Fix: Umstellung auf Socket.io für alle Views und Verbesserung der Event-Registrierung

Änderung:
- Alle Views wurden aktualisiert, um den Daemon WebSocket zu deaktivieren und stattdessen Socket.io für die Event-Registrierung zu verwenden.
- Eine neue Methode `setupSocketEvents` wurde hinzugefügt, um die Socket.io-Events zu registrieren und Protokollausgaben für den Status der Registrierung bereitzustellen.
- Die Logik zur Handhabung von WebSocket-Events wurde vereinfacht und verbessert, um die Stabilität und Nachvollziehbarkeit zu erhöhen.

Diese Anpassung sorgt für eine konsistentere Handhabung von WebSocket-Events und verbessert die Benutzererfahrung durch zuverlässigere Datenaktualisierungen.
This commit is contained in:
Torsten Schulz (local)
2025-09-08 12:06:56 +02:00
parent 975a1dd7ca
commit 917b04fb5e
10 changed files with 159 additions and 49 deletions

View File

@@ -88,7 +88,7 @@ export default {
};
},
computed: {
...mapState(['socket', 'daemonSocket']),
...mapState(['socket']),
allRenovated() {
return Object.values(this.status).every(v => v >= 100);
}
@@ -190,13 +190,25 @@ export default {
},
async mounted() {
await this.loadData();
if (this.socket) this.socket.on('falukantHouseUpdate', this.loadData);
if (this.daemonSocket) this.daemonSocket.addEventListener('message', this.handleDaemonMessage);
this.setupSocketEvents();
},
beforeUnmount() {
if (this.socket) this.socket.off('falukantHouseUpdate', this.loadData);
if (this.daemonSocket) this.daemonSocket.removeEventListener('message', this.handleDaemonMessage);
}
if (this.socket) {
this.socket.off('falukantHouseUpdate', this.loadData);
this.socket.off('falukantUpdateStatus', this.loadData);
}
},
methods: {
setupSocketEvents() {
if (this.socket) {
this.socket.on('falukantHouseUpdate', this.loadData);
this.socket.on('falukantUpdateStatus', this.loadData);
console.log('✅ HouseView: Socket.io Events registriert');
} else {
console.log('⚠️ HouseView: Socket.io noch nicht verfügbar');
setTimeout(() => this.setupSocketEvents(), 1000);
}
}
};
</script>