1.重构实时消息WebSocket连接
2.MySQL备份
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace app\admin\controller\game;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\admin\PushChannelConfigHelper;
|
||||
use app\common\service\GameLiveService;
|
||||
use app\common\service\GameRecordService;
|
||||
use support\Response;
|
||||
@@ -39,21 +38,6 @@ class Live extends Backend
|
||||
return $this->success('', GameLiveService::buildSnapshot($recordId));
|
||||
}
|
||||
|
||||
public function pushConfig(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'url' => PushChannelConfigHelper::wsBaseUrl(),
|
||||
'app_key' => (string) config('plugin.webman.push.app.app_key'),
|
||||
'channel' => 'game-live',
|
||||
'event' => 'bet-updated',
|
||||
]);
|
||||
}
|
||||
|
||||
public function calculate(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
|
||||
49
app/admin/controller/test/GameCurrentStatus.php
Normal file
49
app/admin/controller/test/GameCurrentStatus.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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"]}',
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\test;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\admin\PushChannelConfigHelper;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
|
||||
/**
|
||||
* 推送测试:public-game-period(对局公共频道)
|
||||
*/
|
||||
class PushGamePeriod extends Backend
|
||||
{
|
||||
protected ?object $model = null;
|
||||
|
||||
public function pushConfig(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'url' => PushChannelConfigHelper::wsBaseUrl(),
|
||||
'app_key' => PushChannelConfigHelper::appKey(),
|
||||
'channel' => 'public-game-period',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\test;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\admin\PushChannelConfigHelper;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
|
||||
/**
|
||||
* 推送测试:public-operation-notice(公告广播频道)
|
||||
*/
|
||||
class PushOperationNotice extends Backend
|
||||
{
|
||||
protected ?object $model = null;
|
||||
|
||||
public function pushConfig(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'url' => PushChannelConfigHelper::wsBaseUrl(),
|
||||
'app_key' => PushChannelConfigHelper::appKey(),
|
||||
'channel' => 'public-operation-notice',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\test;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\admin\PushChannelConfigHelper;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
|
||||
/**
|
||||
* 推送测试:private-user-{uuid}(用户私有频道)
|
||||
*/
|
||||
class PushPrivateUser extends Backend
|
||||
{
|
||||
protected ?object $model = null;
|
||||
|
||||
public function pushConfig(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$uuid = trim((string) ($request->get('uuid') ?? $request->post('uuid') ?? ''));
|
||||
if ($uuid === '') {
|
||||
return $this->error(__('Parameter %s can not be empty', ['uuid']));
|
||||
}
|
||||
if (strlen($uuid) > 64 || !preg_match('/^[0-9a-zA-Z_-]+$/', $uuid)) {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'url' => PushChannelConfigHelper::wsBaseUrl(),
|
||||
'app_key' => PushChannelConfigHelper::appKey(),
|
||||
'channel' => 'private-user-' . $uuid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user