Skip to content

Commit

Permalink
Improve ShouldBroadcastNow performance
Browse files Browse the repository at this point in the history
  • Loading branch information
josiasmontag committed Dec 10, 2019
1 parent 0b41342 commit c5c5b75
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Illuminate/Broadcasting/BroadcastManager.php
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Broadcasting\Broadcasters\RedisBroadcaster;
use Illuminate\Contracts\Broadcasting\Factory as FactoryContract;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcherContract;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Pusher\Pusher;
Expand Down Expand Up @@ -108,10 +109,8 @@ public function event($event = null)
*/
public function queue($event)
{
$connection = $event instanceof ShouldBroadcastNow ? 'sync' : null;

if (is_null($connection) && isset($event->connection)) {
$connection = $event->connection;
if ($event instanceof ShouldBroadcastNow) {
return $this->app->make(BusDispatcherContract::class)->dispatchNow(new BroadcastEvent(clone $event));
}

$queue = null;
Expand All @@ -124,7 +123,7 @@ public function queue($event)
$queue = $event->queue;
}

$this->app->make('queue')->connection($connection)->pushOn(
$this->app->make('queue')->connection($event->connection ?? null)->pushOn(
$queue, new BroadcastEvent(clone $event)
);
}
Expand Down

0 comments on commit c5c5b75

Please sign in to comment.