50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace app\admin\controller\test;
|
||
|
||
use app\common\controller\Backend;
|
||
use app\common\library\admin\WebSocketConfigHelper;
|
||
use support\Response;
|
||
use Webman\Http\Request as WebmanRequest;
|
||
|
||
/**
|
||
* WebSocket 测试:状态流(period.tick / period.opened)
|
||
*/
|
||
class GameCurrentStatus extends Backend
|
||
{
|
||
protected ?object $model = null;
|
||
|
||
public function wsConfig(WebmanRequest $request): Response
|
||
{
|
||
$response = $this->initializeBackend($request);
|
||
if ($response !== null) {
|
||
return $response;
|
||
}
|
||
|
||
$subscribeTopics = [
|
||
'period.tick',
|
||
'period.opened',
|
||
'period.locked',
|
||
'period.payout',
|
||
'bet.accepted',
|
||
'wallet.changed',
|
||
'auto.spin.progress',
|
||
];
|
||
|
||
return $this->success('', [
|
||
'name' => 'ws.period',
|
||
'ws_url' => WebSocketConfigHelper::wsUrl(),
|
||
'connect_tip' => '连接成功后会自动订阅下列主题;也可在「发送消息」中手动改订阅。未订阅时不会收到业务推送。',
|
||
'subscribe_topics' => $subscribeTopics,
|
||
'sample_messages' => [
|
||
'{"action":"ping"}',
|
||
'{"action":"subscribe","topics":["period.tick","period.opened"]}',
|
||
'{"action":"subscribe","topics":["bet.accepted","wallet.changed","auto.spin.progress"]}',
|
||
],
|
||
]);
|
||
}
|
||
}
|
||
|