driverSupportsRealtime()) { return; } $data = $this->snapshot->build(); $ms = (int) floor(microtime(true) * 1000); broadcast(new DrawCountdownBroadcast($data, $ms)); } /** * Tick 首尾对比:**数据库**当期指纹({@see DrawHallSnapshotBuilder::hallTargetFingerprint})变了再发, * 载荷仍为 {@see DrawHallSnapshotBuilder::build()}(含未到 tick 时对 `open` 的展示规范化)。 */ public function notifyStatusChangeIfHallDbChanged(?array $fpBefore, ?array $fpAfter, ?array $snapshotPayload): void { if (! $this->driverSupportsRealtime()) { return; } if (($fpBefore['draw_no'] ?? null) === ($fpAfter['draw_no'] ?? null) && ($fpBefore['status'] ?? null) === ($fpAfter['status'] ?? null)) { return; } $this->notifyStatusChange($snapshotPayload); } /** `draw.status_change`(管理端发布后等不与 tick 同路径时使用)。 */ public function notifyStatusChange(?array $data): void { if (! $this->driverSupportsRealtime()) { return; } broadcast(new DrawStatusChangeBroadcast($data, (int) floor(microtime(true) * 1000))); } /** `result.published` */ public function notifyResultPublished(?array $data): void { if (! $this->driverSupportsRealtime()) { return; } broadcast(new DrawResultPublishedBroadcast($data, (int) floor(microtime(true) * 1000))); } private function driverSupportsRealtime(): bool { $default = config('broadcasting.default'); if ($default === null || $default === 'null') { return false; } $driver = config("broadcasting.connections.{$default}.driver") ?? $default; return ! in_array($driver, ['null', 'log'], true); } }