From 353401bc5b253692aed31840235ccce603868727 Mon Sep 17 00:00:00 2001 From: radud Date: Wed, 21 May 2025 19:05:23 +0300 Subject: [PATCH 1/4] Add sockudo support as broadcasting driver --- config/broadcasting.php | 16 ++++++++++ .../Console/BroadcastingInstallCommand.php | 31 +++++++++++++++++++ .../Console/stubs/echo-js-sockudo.stub | 14 +++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub diff --git a/config/broadcasting.php b/config/broadcasting.php index ebc3fb9cf136..904c70b57cc3 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -64,6 +64,22 @@ ], ], + 'sockudo' => [ + 'driver' => 'reverb', + 'key' => env('SOCKUDO_APP_KEY'), + 'secret' => env('SOCKUDO_APP_SECRET'), + 'app_id' => env('SOCKUDO_APP_ID'), + 'options' => [ + 'host' => env('SOCKUDO_HOST'), + 'port' => env('SOCKUDO_PORT', 443), + 'scheme' => env('SOCKUDO_SCHEME', 'https'), + 'useTLS' => env('SOCKUDO_SCHEME', 'https') === 'https', + ], + 'client_options' => [ + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html + ], + ], + 'ably' => [ 'driver' => 'ably', 'key' => env('ABLY_KEY'), diff --git a/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php b/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php index ba42ab6f9ebd..5e00da3bc183 100644 --- a/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php +++ b/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php @@ -33,6 +33,7 @@ class BroadcastingInstallCommand extends Command {--reverb : Install Laravel Reverb as the default broadcaster} {--pusher : Install Pusher as the default broadcaster} {--ably : Install Ably as the default broadcaster} + {--sockudo: Install Sockudo as the default broadcaster} {--without-node : Do not prompt to install Node dependencies}'; /** @@ -207,6 +208,7 @@ protected function collectDriverConfig() match ($this->driver) { 'pusher' => $this->collectPusherConfig(), 'ably' => $this->collectAblyConfig(), + 'sockudo' => $this->collectSockudoConfig(), default => null, }; } @@ -289,6 +291,30 @@ protected function collectAblyConfig() ], $this->laravel->basePath('.env')); } + /** + * Collect the Sockudo configuration. + * + * @return void + */ + protected function collectSockudoConfig() + { + $appId = text('Sockudo App ID', 'Enter your Pusher app ID'); + $key = password('Sockudo App Key', 'Enter your Pusher app key'); + $secret = password('Sockudo App Secret', 'Enter your Pusher app secret'); + + Env::writeVariables([ + 'SOCKUDO_APP_ID' => $appId, + 'SOCKUDO_APP_KEY' => $key, + 'SOCKUDO_APP_SECRET' => $secret, + 'SOCKUDO_PORT' => 443, + 'SOCKUDO_SCHEME' => 'https', + 'VITE_SOCKUDO_APP_KEY' => '${SOCKUDO_APP_KEY}', + 'VITE_SOCKUDO_HOST' => '${SOCKUDO_HOST}', + 'VITE_SOCKUDO' => '${SOCKUDO_PORT}', + 'VITE_SOCKUDO_SCHEME' => '${SOCKUDO_SCHEME}', + ], $this->laravel->basePath('.env')); + } + /** * Inject Echo configuration into the application's main file. * @@ -460,10 +486,15 @@ protected function resolveDriver(): string return 'ably'; } + if ($this->option('sockudo')) { + return 'sockudo'; + } + return select('Which broadcasting driver would you like to use?', [ 'reverb' => 'Laravel Reverb', 'pusher' => 'Pusher', 'ably' => 'Ably', + 'sockudo' => 'Sockudo', ]); } diff --git a/src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub b/src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub new file mode 100644 index 000000000000..a2c8ed26f778 --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub @@ -0,0 +1,14 @@ +import Echo from 'laravel-echo'; + +import Pusher from 'pusher-js'; +window.Pusher = Pusher; + +window.Echo = new Echo({ + broadcaster: 'sockudo', + key: import.meta.env.VITE_SOCKUDO_APP_KEY, + wsHost: import.meta.env.VITE_SOCKUDO_HOST, + wsPort: import.meta.env.VITE_SOCKUDO_PORT ?? 80, + wssPort: import.meta.env.VITE_SOCKUDO_PORT ?? 443, + forceTLS: (import.meta.env.VITE_SOCKUDO_SCHEME ?? 'https') === 'https', + enabledTransports: ['ws', 'wss'], +}); From bdaf8e8f979a98feaa9cfc8b5af42170dfc9262b Mon Sep 17 00:00:00 2001 From: Diaconu Radu-Mihai <52667211+radudiaconu0@users.noreply.github.com> Date: Wed, 21 May 2025 21:40:28 +0300 Subject: [PATCH 2/4] Update broadcasting.php --- config/broadcasting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/broadcasting.php b/config/broadcasting.php index 904c70b57cc3..a910c12f5ed3 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -65,7 +65,7 @@ ], 'sockudo' => [ - 'driver' => 'reverb', + 'driver' => 'sockudo', 'key' => env('SOCKUDO_APP_KEY'), 'secret' => env('SOCKUDO_APP_SECRET'), 'app_id' => env('SOCKUDO_APP_ID'), From 74351a89041abeaebcb6b47a7275be19fe689a44 Mon Sep 17 00:00:00 2001 From: radud Date: Wed, 21 May 2025 21:57:26 +0300 Subject: [PATCH 3/4] install pusher/pusher-php-server when choose sockudo as broadcast driver --- config/broadcasting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/broadcasting.php b/config/broadcasting.php index a910c12f5ed3..863af9b2c267 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -65,7 +65,7 @@ ], 'sockudo' => [ - 'driver' => 'sockudo', + 'driver' => 'pusher', 'key' => env('SOCKUDO_APP_KEY'), 'secret' => env('SOCKUDO_APP_SECRET'), 'app_id' => env('SOCKUDO_APP_ID'), From da7ce8c1d7f6d07ea55363f885a4d08364903db3 Mon Sep 17 00:00:00 2001 From: radud Date: Wed, 21 May 2025 22:30:42 +0300 Subject: [PATCH 4/4] remove sockudo driver (not necessary beacuse of pusher compatibility) --- config/broadcasting.php | 14 ++++----- .../Console/BroadcastingInstallCommand.php | 31 ------------------- .../Console/stubs/echo-js-sockudo.stub | 14 --------- 3 files changed, 7 insertions(+), 52 deletions(-) delete mode 100644 src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub diff --git a/config/broadcasting.php b/config/broadcasting.php index 863af9b2c267..83e8661ed50f 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -66,14 +66,14 @@ 'sockudo' => [ 'driver' => 'pusher', - 'key' => env('SOCKUDO_APP_KEY'), - 'secret' => env('SOCKUDO_APP_SECRET'), - 'app_id' => env('SOCKUDO_APP_ID'), + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'host' => env('SOCKUDO_HOST'), - 'port' => env('SOCKUDO_PORT', 443), - 'scheme' => env('SOCKUDO_SCHEME', 'https'), - 'useTLS' => env('SOCKUDO_SCHEME', 'https') === 'https', + 'host' => env('PUSHER_HOST'), + 'port' => env('PUSHER_PORT', 443), + 'scheme' => env('PUSHER_SCHEME', 'https'), + 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', ], 'client_options' => [ // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html diff --git a/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php b/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php index 5e00da3bc183..ba42ab6f9ebd 100644 --- a/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php +++ b/src/Illuminate/Foundation/Console/BroadcastingInstallCommand.php @@ -33,7 +33,6 @@ class BroadcastingInstallCommand extends Command {--reverb : Install Laravel Reverb as the default broadcaster} {--pusher : Install Pusher as the default broadcaster} {--ably : Install Ably as the default broadcaster} - {--sockudo: Install Sockudo as the default broadcaster} {--without-node : Do not prompt to install Node dependencies}'; /** @@ -208,7 +207,6 @@ protected function collectDriverConfig() match ($this->driver) { 'pusher' => $this->collectPusherConfig(), 'ably' => $this->collectAblyConfig(), - 'sockudo' => $this->collectSockudoConfig(), default => null, }; } @@ -291,30 +289,6 @@ protected function collectAblyConfig() ], $this->laravel->basePath('.env')); } - /** - * Collect the Sockudo configuration. - * - * @return void - */ - protected function collectSockudoConfig() - { - $appId = text('Sockudo App ID', 'Enter your Pusher app ID'); - $key = password('Sockudo App Key', 'Enter your Pusher app key'); - $secret = password('Sockudo App Secret', 'Enter your Pusher app secret'); - - Env::writeVariables([ - 'SOCKUDO_APP_ID' => $appId, - 'SOCKUDO_APP_KEY' => $key, - 'SOCKUDO_APP_SECRET' => $secret, - 'SOCKUDO_PORT' => 443, - 'SOCKUDO_SCHEME' => 'https', - 'VITE_SOCKUDO_APP_KEY' => '${SOCKUDO_APP_KEY}', - 'VITE_SOCKUDO_HOST' => '${SOCKUDO_HOST}', - 'VITE_SOCKUDO' => '${SOCKUDO_PORT}', - 'VITE_SOCKUDO_SCHEME' => '${SOCKUDO_SCHEME}', - ], $this->laravel->basePath('.env')); - } - /** * Inject Echo configuration into the application's main file. * @@ -486,15 +460,10 @@ protected function resolveDriver(): string return 'ably'; } - if ($this->option('sockudo')) { - return 'sockudo'; - } - return select('Which broadcasting driver would you like to use?', [ 'reverb' => 'Laravel Reverb', 'pusher' => 'Pusher', 'ably' => 'Ably', - 'sockudo' => 'Sockudo', ]); } diff --git a/src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub b/src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub deleted file mode 100644 index a2c8ed26f778..000000000000 --- a/src/Illuminate/Foundation/Console/stubs/echo-js-sockudo.stub +++ /dev/null @@ -1,14 +0,0 @@ -import Echo from 'laravel-echo'; - -import Pusher from 'pusher-js'; -window.Pusher = Pusher; - -window.Echo = new Echo({ - broadcaster: 'sockudo', - key: import.meta.env.VITE_SOCKUDO_APP_KEY, - wsHost: import.meta.env.VITE_SOCKUDO_HOST, - wsPort: import.meta.env.VITE_SOCKUDO_PORT ?? 80, - wssPort: import.meta.env.VITE_SOCKUDO_PORT ?? 443, - forceTLS: (import.meta.env.VITE_SOCKUDO_SCHEME ?? 'https') === 'https', - enabledTransports: ['ws', 'wss'], -});