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:
@@ -55,20 +55,14 @@ export default {
|
||||
...mapGetters(['menu']),
|
||||
},
|
||||
async mounted() {
|
||||
await this.fetchStatus();
|
||||
if (this.socket) {
|
||||
this.socket.on("falukantUpdateStatus", this.fetchStatus);
|
||||
}
|
||||
if (this.daemonSocket) {
|
||||
this.daemonSocket.addEventListener("message", this.handleDaemonSocketMessage);
|
||||
}
|
||||
await this.fetchStatus();
|
||||
this.setupSocketEvents();
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.socket) {
|
||||
this.socket.off("falukantUpdateStatus", this.fetchStatus);
|
||||
}
|
||||
if (this.daemonSocket) {
|
||||
this.daemonSocket.removeEventListener("message", this.handleDaemonSocketMessage);
|
||||
this.socket.off("stock_change", this.fetchStatus);
|
||||
this.socket.off("familychanged", this.fetchStatus);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -110,7 +104,26 @@ export default {
|
||||
}
|
||||
},
|
||||
// Daemon WebSocket deaktiviert - verwende Socket.io Events
|
||||
// Diese Methode wird nicht mehr verwendet
|
||||
setupSocketEvents() {
|
||||
if (this.socket) {
|
||||
this.socket.on('falukantUpdateStatus', (data) => {
|
||||
console.log('📨 StatusBar: falukantUpdateStatus empfangen:', data);
|
||||
this.fetchStatus();
|
||||
});
|
||||
this.socket.on('stock_change', (data) => {
|
||||
console.log('📨 StatusBar: stock_change empfangen:', data);
|
||||
this.fetchStatus();
|
||||
});
|
||||
this.socket.on('familychanged', (data) => {
|
||||
console.log('📨 StatusBar: familychanged empfangen:', data);
|
||||
this.fetchStatus();
|
||||
});
|
||||
console.log('✅ StatusBar: Socket.io Events registriert');
|
||||
} else {
|
||||
console.log('⚠️ StatusBar: Socket.io noch nicht verfügbar');
|
||||
setTimeout(() => this.setupSocketEvents(), 1000);
|
||||
}
|
||||
},
|
||||
openPage(url, hasSubmenu = false) {
|
||||
if (hasSubmenu) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user