Skip to content

[9.x] Drop pusher/pusher-php-server 4.x #36528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"phpunit/phpunit": "Required to use assertions and run tests (^9.4).",
"predis/predis": "Required to use the predis connector (^1.1.2).",
"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).",
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^5.0).",
"symfony/cache": "Required to PSR-6 cache bridge (^5.3).",
"symfony/filesystem": "Required to enable support for relative symbolic links (^5.3).",
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).",
Expand Down
41 changes: 7 additions & 34 deletions src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,46 +111,19 @@ public function broadcast(array $channels, $event, array $payload = [])
{
$socket = Arr::pull($payload, '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
);

if ((is_array($response) && $response['status'] >= 200 && $response['status'] <= 299)
|| $response === true) {
return;
}
$parameters = $socket !== null ? ['socket_id' => $socket] : [];

try {
$this->pusher->trigger(
$this->formatChannels($channels), $event, $payload, $parameters
);
} 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.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Broadcasting/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
},
"suggest": {
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0)."
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^5.0)."
},
"config": {
"sort-packages": true
Expand Down