feat: 优化 DrawCurrentController 和 LotteryHallRealtimeBroadcaster 的响应结构
This commit is contained in:
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user