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:
@@ -152,7 +152,7 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['daemonSocket']),
|
||||
...mapState(['socket']),
|
||||
getAvatarStyle() {
|
||||
if (!this.falukantUser) return {};
|
||||
const { gender, age } = this.falukantUser.character;
|
||||
@@ -203,18 +203,20 @@ export default {
|
||||
return window.navigator.language || 'en-US';
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
socket(newSocket) {
|
||||
if (newSocket) {
|
||||
console.log('🔌 Socket.io verfügbar - registriere Events');
|
||||
this.setupSocketEvents();
|
||||
}
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.fetchFalukantUser();
|
||||
await this.fetchAllStock();
|
||||
await this.fetchProductions();
|
||||
// Daemon WebSocket deaktiviert - verwende Socket.io für alle Events
|
||||
if (this.socket) {
|
||||
this.socket.on("falukantUserUpdated", this.fetchFalukantUser);
|
||||
this.socket.on("production_ready", this.handleProductionReadyEvent);
|
||||
console.log('✅ FalukantOverviewView: Socket.io Events registriert');
|
||||
} else {
|
||||
console.log('⚠️ FalukantOverviewView: Kein Socket.io verfügbar');
|
||||
}
|
||||
this.setupSocketEvents();
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.socket) {
|
||||
@@ -224,6 +226,27 @@ export default {
|
||||
// Daemon WebSocket deaktiviert - keine Cleanup nötig
|
||||
},
|
||||
methods: {
|
||||
setupSocketEvents() {
|
||||
if (this.socket) {
|
||||
this.socket.on("falukantUserUpdated", this.fetchFalukantUser);
|
||||
this.socket.on("production_ready", this.handleProductionReadyEvent);
|
||||
this.socket.on("falukantUpdateStatus", (data) => {
|
||||
console.log('📨 FalukantOverviewView: falukantUpdateStatus empfangen:', data);
|
||||
this.fetchFalukantUser();
|
||||
});
|
||||
this.socket.on("falukantBranchUpdate", (data) => {
|
||||
console.log('📨 FalukantOverviewView: falukantBranchUpdate empfangen:', data);
|
||||
this.fetchFalukantUser();
|
||||
});
|
||||
console.log('✅ FalukantOverviewView: Socket.io Events registriert');
|
||||
} else {
|
||||
console.log('⚠️ FalukantOverviewView: Socket.io noch nicht verfügbar, versuche es später...');
|
||||
// Versuche es nach kurzer Verzögerung erneut
|
||||
setTimeout(() => {
|
||||
this.setupSocketEvents();
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
getAgeGroup(age) {
|
||||
if (age <= 1) return "0-1";
|
||||
if (age <= 3) return "2-3";
|
||||
|
||||
Reference in New Issue
Block a user