1.重构websocket连接
This commit is contained in:
@@ -6,6 +6,7 @@ use app\common\controller\Backend;
|
||||
use app\common\library\admin\WebSocketConfigHelper;
|
||||
use app\common\service\GameLiveService;
|
||||
use app\common\service\GameRecordService;
|
||||
use app\common\service\GameWebSocketAuthHelper;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
|
||||
@@ -67,9 +68,19 @@ class Live extends Backend
|
||||
'auto.spin.progress',
|
||||
];
|
||||
|
||||
$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.admin.live',
|
||||
'ws_url' => WebSocketConfigHelper::wsUrl($request),
|
||||
'ws_url' => $wsUrl,
|
||||
'ws_base_url' => $baseWsUrl,
|
||||
'admin_ws_token' => (string) ($adminWs['token'] ?? ''),
|
||||
'admin_ws_token_ttl' => (int) ($adminWs['ttl'] ?? 0),
|
||||
'connect_tip' => 'The admin live page auto-subscribes topics for status, draw result and payout events.',
|
||||
'subscribe_topics' => $topics,
|
||||
'sample_messages' => [
|
||||
|
||||
Reference in New Issue
Block a user