优化推送消息
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\admin\controller\game;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\admin\PushChannelConfigHelper;
|
||||
use app\common\service\GameLiveService;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
@@ -44,12 +45,8 @@ class Live extends Backend
|
||||
return $response;
|
||||
}
|
||||
|
||||
$ws = (string) config('plugin.webman.push.app.websocket');
|
||||
$ws = str_replace('websocket://', 'ws://', $ws);
|
||||
$ws = str_replace('0.0.0.0', '127.0.0.1', $ws);
|
||||
|
||||
return $this->success('', [
|
||||
'url' => $ws,
|
||||
'url' => PushChannelConfigHelper::wsBaseUrl(),
|
||||
'app_key' => (string) config('plugin.webman.push.app.app_key'),
|
||||
'channel' => 'game-live',
|
||||
'event' => 'bet-updated',
|
||||
|
||||
@@ -11,12 +11,27 @@ final class PushChannelConfigHelper
|
||||
{
|
||||
public static function wsBaseUrl(): string
|
||||
{
|
||||
$client = trim((string) config('plugin.webman.push.app.websocket_client'));
|
||||
if ($client !== '') {
|
||||
return self::normalizeClientWsBase($client);
|
||||
}
|
||||
|
||||
$ws = (string) config('plugin.webman.push.app.websocket');
|
||||
$ws = str_replace('websocket://', 'ws://', $ws);
|
||||
|
||||
return str_replace('0.0.0.0', '127.0.0.1', $ws);
|
||||
}
|
||||
|
||||
private static function normalizeClientWsBase(string $url): string
|
||||
{
|
||||
$url = rtrim(trim($url), '/');
|
||||
if (str_starts_with($url, 'websocket://')) {
|
||||
return str_replace('websocket://', 'ws://', $url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function appKey(): string
|
||||
{
|
||||
return (string) config('plugin.webman.push.app.app_key');
|
||||
|
||||
Reference in New Issue
Block a user