From fd757180d16e1982cc494ec652072f4c185897a9 Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 16 May 2026 10:31:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20DrawCurrentControl?= =?UTF-8?q?ler=20=E5=92=8C=20LotteryHallRealtimeBroadcaster=20=E7=9A=84?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/V1/Draw/DrawCurrentController.php | 5 ++++- app/Services/Draw/LotteryHallRealtimeBroadcaster.php | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/V1/Draw/DrawCurrentController.php b/app/Http/Controllers/Api/V1/Draw/DrawCurrentController.php index b988e4c..6d01d4d 100644 --- a/app/Http/Controllers/Api/V1/Draw/DrawCurrentController.php +++ b/app/Http/Controllers/Api/V1/Draw/DrawCurrentController.php @@ -19,6 +19,9 @@ final class DrawCurrentController extends Controller public function __invoke(Request $request): JsonResponse { - return ApiResponse::success($this->snapshot->build()); + return ApiResponse::success([ + 'server_now_ms' => (int) floor(microtime(true) * 1000), + 'data' => $this->snapshot->build(), + ]); } } diff --git a/app/Services/Draw/LotteryHallRealtimeBroadcaster.php b/app/Services/Draw/LotteryHallRealtimeBroadcaster.php index fd7d78c..f112f2f 100644 --- a/app/Services/Draw/LotteryHallRealtimeBroadcaster.php +++ b/app/Services/Draw/LotteryHallRealtimeBroadcaster.php @@ -21,17 +21,16 @@ final class LotteryHallRealtimeBroadcaster private readonly DrawHallSnapshotBuilder $snapshot, ) {} - /** 每秒调度:`draw.countdown` */ + /** 每秒调度:`draw.countdown` 仅发送轻量心跳,不重查全量大厅快照。 */ public function countdownPulse(): void { if (! $this->driverSupportsRealtime()) { return; } - $data = $this->snapshot->build(); $ms = (int) floor(microtime(true) * 1000); - broadcast(new DrawCountdownBroadcast($data, $ms)); + broadcast(new DrawCountdownBroadcast(null, $ms)); } /**