option('interval')); $uptimeEvery = max(1, (int) $this->option('uptime-every')); $weatherEvery = max(1, (int) $this->option('weather-every')); $this->info("HUD-Broadcaster läuft - stats:{$interval}s uptime:".($interval * $uptimeEvery)."s weather:".($interval * $weatherEvery).'s'); $tick = 0; while (true) { $this->safeBroadcast(fn () => broadcast(new SystemStatsBroadcast($stats->collect())), 'stats'); if ($tick % $uptimeEvery === 0) { $this->safeBroadcast(fn () => broadcast(new UptimeBroadcast($uptime->collect())), 'uptime'); } if ($tick % $weatherEvery === 0) { $this->safeBroadcast(fn () => broadcast(new WeatherBroadcast($weather->fetch())), 'weather'); } $tick++; sleep($interval); } } protected function safeBroadcast(\Closure $fn, string $label): void { try { $fn(); } catch (\Throwable $e) { $this->error("Broadcast {$label} fehlgeschlagen: ".$e->getMessage()); } } }