Removed $this->connection from RedisPusherBroadcaster

This commit is contained in:
Alex Renoki 2020-08-24 12:42:01 +03:00
parent e67fe3828d
commit d6b6135d7c
3 changed files with 6 additions and 15 deletions

View File

@ -20,8 +20,7 @@ trait PushesToPusher
return new RedisPusherBroadcaster( return new RedisPusherBroadcaster(
new Pusher($app['key'], $app['secret'], $app['id'], config('broadcasting.connections.websockets.options', [])), new Pusher($app['key'], $app['secret'], $app['id'], config('broadcasting.connections.websockets.options', [])),
$app['id'], $app['id'],
app('redis'), app('redis')
config('broadcasting.connections.websockets.connection', null)
); );
} }

View File

@ -35,27 +35,18 @@ class RedisPusherBroadcaster extends Broadcaster
*/ */
protected $redis; protected $redis;
/**
* The Redis connection to use for broadcasting.
*
* @var string|null
*/
protected $connection;
/** /**
* Create a new broadcaster instance. * Create a new broadcaster instance.
* *
* @param Pusher $pusher * @param Pusher $pusher
* @param mixed $appId * @param mixed $appId
* @param \Illuminate\Contracts\Redis\Factory $redis * @param \Illuminate\Contracts\Redis\Factory $redis
* @param string|null $connection
*/ */
public function __construct(Pusher $pusher, $appId, Redis $redis, $connection = null) public function __construct(Pusher $pusher, $appId, Redis $redis)
{ {
$this->pusher = $pusher; $this->pusher = $pusher;
$this->appId = $appId; $this->appId = $appId;
$this->redis = $redis; $this->redis = $redis;
$this->connection = $connection;
} }
/** /**
@ -133,7 +124,9 @@ class RedisPusherBroadcaster extends Broadcaster
*/ */
public function broadcast(array $channels, $event, array $payload = []) public function broadcast(array $channels, $event, array $payload = [])
{ {
$connection = $this->redis->connection($this->connection); $connection = $this->redis->connection(
config('websockets.replication.redis.connection') ?: 'default'
);
$payload = json_encode([ $payload = json_encode([
'appId' => $this->appId, 'appId' => $this->appId,

View File

@ -105,8 +105,7 @@ class WebSocketsServiceProvider extends ServiceProvider
return new RedisPusherBroadcaster( return new RedisPusherBroadcaster(
$pusher, $pusher,
$config['app_id'], $config['app_id'],
$this->app->make('redis'), $this->app->make('redis')
$config['connection'] ?? null
); );
}); });
} }