added wss tools

This commit is contained in:
2026-06-17 21:26:08 +03:30
parent cc5808e755
commit b66a8611cd
5 changed files with 140 additions and 47 deletions
@@ -150,6 +150,8 @@ class ProductController extends SuperController
$product = Product::findOrFail($id);
$oldOffsetPercent = (float) ($product->price_offset_percent ?? 0);
unset($data['trade_by_quantity']);
if (
Product::hasPriceOffsetColumn()
&& $product->reading_method
+25 -6
View File
@@ -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', ''));