added wss tools
This commit is contained in:
@@ -11,19 +11,38 @@ class WebsocketBroadcastService
|
||||
|
||||
public function triggerBaseUrl(): ?string
|
||||
{
|
||||
$fromEnv = trim((string) (env('WSS_LINK') ?: env('wssLink', '')));
|
||||
if ($fromEnv !== '') {
|
||||
return rtrim($fromEnv, '/');
|
||||
$config = app(ConfigService::class);
|
||||
$port = $config->getInt('wss_http_port', 0);
|
||||
|
||||
if ($port > 0) {
|
||||
$host = trim($config->getString('wss_trigger_host', '127.0.0.1'));
|
||||
if ($host === '') {
|
||||
$host = '127.0.0.1';
|
||||
}
|
||||
|
||||
$scheme = trim($config->getString('wss_trigger_scheme', 'http'));
|
||||
if ($scheme === '') {
|
||||
$scheme = 'http';
|
||||
}
|
||||
|
||||
return rtrim("{$scheme}://{$host}:{$port}", '/');
|
||||
}
|
||||
|
||||
$fromSetting = trim((string) app(ConfigService::class)->getString('wss_link', ''));
|
||||
if ($fromSetting !== '') {
|
||||
return rtrim($fromSetting, '/');
|
||||
// سازگاری با دیپلویهای قدیمی (wss_link کامل)
|
||||
$legacyLink = trim($config->getString('wss_link', ''));
|
||||
if ($legacyLink !== '') {
|
||||
return rtrim($legacyLink, '/');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** پورت WebSocket داخلی — برای دیپلوی لایتاسپید/docker (همان پروژه) */
|
||||
public function socketPort(): int
|
||||
{
|
||||
return app(ConfigService::class)->getInt('wss_socket_port', 0);
|
||||
}
|
||||
|
||||
public function triggerPath(): string
|
||||
{
|
||||
$path = trim((string) app(ConfigService::class)->getString('wss_trigger_path', ''));
|
||||
|
||||
Reference in New Issue
Block a user