1.优化ws游戏对局推送消息
This commit is contained in:
@@ -608,7 +608,7 @@ final class GameLiveService
|
||||
} catch (Throwable) {
|
||||
}
|
||||
self::publishPublicPeriodOpened((string) $record['period_no'], $finalNumber, $now);
|
||||
self::publishPublicPeriodPayout((string) $record['period_no'], $finalNumber, $payoutUntil);
|
||||
self::publishPublicPeriodPayout($rid, (string) $record['period_no'], $finalNumber, $payoutUntil, $now);
|
||||
$jackpotHits = is_array($settleOut['jackpot_hits'] ?? null) ? $settleOut['jackpot_hits'] : [];
|
||||
GameWebSocketEventBus::publish('admin.live.opened', [
|
||||
'period_id' => $rid,
|
||||
@@ -661,6 +661,11 @@ final class GameLiveService
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$periodNo = is_string($row['period_no'] ?? null) ? (string) $row['period_no'] : '';
|
||||
$resultNumber = filter_var($row['result_number'] ?? 0, FILTER_VALIDATE_INT);
|
||||
if ($resultNumber === false || $resultNumber < 1) {
|
||||
$resultNumber = null;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('game_record')->where('id', $id)->update([
|
||||
@@ -676,6 +681,7 @@ final class GameLiveService
|
||||
}
|
||||
GameHotDataCoordinator::afterGameRecordCommitted($id);
|
||||
GameRecordStatService::refreshForRecordId($id);
|
||||
self::publishPublicPeriodFinished($id, $periodNo, $resultNumber);
|
||||
self::publishSnapshot(null);
|
||||
} finally {
|
||||
GameHotDataLock::release(GameHotDataLock::TYPE_GAME_RECORD, (string) $id, $lock['token'], $lock['redis_lock']);
|
||||
@@ -1003,14 +1009,43 @@ final class GameLiveService
|
||||
}
|
||||
|
||||
/**
|
||||
* 派彩阶段开始(开奖后宽限期内推送)
|
||||
* 派彩阶段开始(开奖后宽限期内推送)。
|
||||
* 客户端应以 payout_until 与 server_time 做倒计时,勿用 period.tick 或上期 countdown。
|
||||
*/
|
||||
private static function publishPublicPeriodPayout(string $periodNo, int $resultNumber, int $payoutUntil): void
|
||||
private static function publishPublicPeriodPayout(int $periodId, string $periodNo, int $resultNumber, int $payoutUntil, int $serverTime): void
|
||||
{
|
||||
$grace = self::getPayoutGraceSeconds();
|
||||
$remaining = max(0, $payoutUntil - $serverTime);
|
||||
GameWebSocketEventBus::publish(self::EVT_PERIOD_PAYOUT, [
|
||||
'period_id' => $periodId,
|
||||
'period_no' => $periodNo,
|
||||
'result_number' => $resultNumber,
|
||||
'payout_until' => $payoutUntil,
|
||||
'payout_seconds' => $grace,
|
||||
'payout_remaining_seconds' => $remaining,
|
||||
'server_time' => $serverTime,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 派彩宽限期结束、进入下一期前:推送本期收尾帧(每期一次)。
|
||||
*/
|
||||
private static function publishPublicPeriodFinished(int $periodId, string $periodNo, ?int $resultNumber): void
|
||||
{
|
||||
if ($periodNo === '') {
|
||||
return;
|
||||
}
|
||||
if (!self::markBoundaryFrameOnce($periodNo, 'finished')) {
|
||||
return;
|
||||
}
|
||||
GameWebSocketEventBus::publish(self::EVT_PERIOD_TICK, [
|
||||
'period_id' => $periodId,
|
||||
'period_no' => $periodNo,
|
||||
'status' => 'finished',
|
||||
'countdown' => 0,
|
||||
'bet_close_in' => 0,
|
||||
'result_number' => $resultNumber,
|
||||
'runtime_enabled' => GameRecordService::isLiveRuntimeEnabled(),
|
||||
'server_time' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user