1.优化websocket接口,新增赔率参数

This commit is contained in:
2026-05-15 16:24:19 +08:00
parent 575aa279bd
commit 91229f4477
13 changed files with 434 additions and 40 deletions

View File

@@ -6,6 +6,7 @@ namespace app\process;
use app\common\service\GameWebSocketEventBus;
use app\common\service\GameLiveService;
use app\common\service\GameWebSocketPayloadHelper;
use Workerman\Connection\TcpConnection;
use Workerman\Timer;
@@ -169,6 +170,7 @@ class GameWebSocketServer
'event' => 'ws.subscribed',
'topics' => $connection->topics,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
self::pushAdminTestOddsPreview($connection, $connection->topics);
return;
}
@@ -194,4 +196,26 @@ class GameWebSocketServer
$connection->topics = [];
unset(self::$connections[$connection->id]);
}
/**
* 后台联调:订阅赔率相关主题后立即推送演示帧(库内样例玩家,带 is_test / preview
*
* @param list<string> $topics
*/
private static function pushAdminTestOddsPreview(TcpConnection $connection, array $topics): void
{
$frames = GameWebSocketPayloadHelper::adminTestPushFrames($topics);
if ($frames === []) {
return;
}
$serverTime = time();
foreach ($frames as $frame) {
$connection->send(json_encode([
'event' => $frame['event'],
'topic' => $frame['topic'],
'data' => $frame['data'],
'server_time' => $serverTime,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
}
}
}