diff --git a/composer.json b/composer.json index 636b854d62b2..58b455d68210 100644 --- a/composer.json +++ b/composer.json @@ -148,7 +148,7 @@ "phpunit/phpunit": "Required to use assertions and run tests (^8.5.19|^9.5.8).", "predis/predis": "Required to use the predis connector (^1.1.9).", "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", - "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0).", + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).", "symfony/cache": "Required to PSR-6 cache bridge (^5.4).", "symfony/filesystem": "Required to enable support for relative symbolic links (^5.4).", "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).", diff --git a/src/Illuminate/Broadcasting/BroadcastManager.php b/src/Illuminate/Broadcasting/BroadcastManager.php index a4957cde900f..1fcf38c76244 100644 --- a/src/Illuminate/Broadcasting/BroadcastManager.php +++ b/src/Illuminate/Broadcasting/BroadcastManager.php @@ -4,6 +4,7 @@ use Ably\AblyRest; use Closure; +use GuzzleHttp\Client as GuzzleClient; use Illuminate\Broadcasting\Broadcasters\AblyBroadcaster; use Illuminate\Broadcasting\Broadcasters\LogBroadcaster; use Illuminate\Broadcasting\Broadcasters\NullBroadcaster; @@ -215,7 +216,8 @@ protected function createPusherDriver(array $config) { $pusher = new Pusher( $config['key'], $config['secret'], - $config['app_id'], $config['options'] ?? [] + $config['app_id'], $config['options'] ?? [], + new GuzzleClient($config['client_options'] ?? []) ); if ($config['log'] ?? false) { diff --git a/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php b/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php index 6b41bc740e9b..65f211405b2f 100644 --- a/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php +++ b/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php @@ -116,46 +116,19 @@ protected function decodePusherResponse($request, $response) public function broadcast(array $channels, $event, array $payload = []) { $socket = Arr::pull($payload, 'socket'); + $parameters = $socket !== null ? ['socket_id' => $socket] : []; - if ($this->pusherServerIsVersionFiveOrGreater()) { - $parameters = $socket !== null ? ['socket_id' => $socket] : []; - - try { - $this->pusher->trigger( - $this->formatChannels($channels), $event, $payload, $parameters - ); - } catch (ApiErrorException $e) { - throw new BroadcastException( - sprintf('Pusher error: %s.', $e->getMessage()) - ); - } - } else { - $response = $this->pusher->trigger( - $this->formatChannels($channels), $event, $payload, $socket, true + try { + $this->pusher->trigger( + $this->formatChannels($channels), $event, $payload, $parameters ); - - if ((is_array($response) && $response['status'] >= 200 && $response['status'] <= 299) - || $response === true) { - return; - } - + } catch (ApiErrorException $e) { throw new BroadcastException( - ! empty($response['body']) - ? sprintf('Pusher error: %s.', $response['body']) - : 'Failed to connect to Pusher.' + sprintf('Pusher error: %s.', $e->getMessage()) ); } } - /** - * Determine if the Pusher PHP server is version 5.0 or greater. - * - * @return bool - */ - protected function pusherServerIsVersionFiveOrGreater() - { - return class_exists(ApiErrorException::class); - } /** * Get the Pusher SDK instance. diff --git a/src/Illuminate/Broadcasting/composer.json b/src/Illuminate/Broadcasting/composer.json index fe6ea00b1237..cf995827851a 100644 --- a/src/Illuminate/Broadcasting/composer.json +++ b/src/Illuminate/Broadcasting/composer.json @@ -34,7 +34,7 @@ } }, "suggest": { - "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0)." + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0)." }, "config": { "sort-packages": true