Files
webman-buildadmin/app/common/library/admin/PushChannelConfigHelper.php
2026-04-20 14:49:02 +08:00

40 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace app\common\library\admin;
/**
* 后台推送测试页:读取 webman/push 配置(与 game/Live::pushConfig 口径一致)
*/
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');
}
}