initializeBackend($request); if ($response !== null) { return $response; } $subscribeTopics = [ 'period.tick', 'period.locked', 'period.opened', 'period.payout', 'period.payout.tick', 'bet.win', 'user.streak', 'wallet.changed', 'bet.accepted', 'jackpot.hit', 'auto.spin.progress', 'admin.live.snapshot', 'admin.live.opened', ]; $oddsPushTopics = GameWebSocketPayloadHelper::ODDS_PUSH_TOPICS; $testPlayerOdds = GameWebSocketPayloadHelper::adminTestPlayerOddsSnapshot(); $adminId = $this->auth ? (int) ($this->auth->id ?? 0) : 0; $adminWs = GameWebSocketAuthHelper::issueAdminWsToken($adminId); $baseWsUrl = WebSocketConfigHelper::wsUrl($request); $wsUrl = WebSocketConfigHelper::appendTokensToWsUrl($baseWsUrl, [ 'admin_ws_token' => (string) ($adminWs['token'] ?? ''), ]); return $this->success('', [ 'name' => 'ws.period', 'ws_url' => $wsUrl, 'ws_base_url' => $baseWsUrl, 'admin_ws_token' => (string) ($adminWs['token'] ?? ''), 'admin_ws_token_ttl' => (int) ($adminWs['ttl'] ?? 0), 'connect_tip' => '连接成功后将自动订阅下列主题。真实业务仅在有玩家下注/结算时推送赔率;本页联调会在订阅后额外推送带 is_test/preview 的演示帧(见下方测试玩家赔率)。', 'subscribe_topics' => $subscribeTopics, 'odds_push_topics' => $oddsPushTopics, 'player_odds_fields' => ['current_streak', 'streak_level', 'odds_factor', 'is_jackpot'], 'test_player_odds' => $testPlayerOdds, 'test_push_topics' => $oddsPushTopics, 'sample_messages' => [ '{"action":"ping"}', '{"action":"subscribe","topics":["period.tick","user.streak","period.opened","period.locked","period.payout"]}', '{"action":"subscribe","topics":["user.streak","wallet.changed","bet.accepted","auto.spin.progress"]}', ], ]); } }