From fd534d3d23aada74e0bb74b38b49c52eebcf2a1d Mon Sep 17 00:00:00 2001 From: freek Date: Thu, 22 Nov 2018 00:14:22 +0100 Subject: [PATCH] nitpicks --- .../Http/Controllers/StatusController.php | 1 - src/LaravelEcho/Pusher/Channels/Channel.php | 20 ++++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/LaravelEcho/Http/Controllers/StatusController.php b/src/LaravelEcho/Http/Controllers/StatusController.php index c487006..0924f2b 100644 --- a/src/LaravelEcho/Http/Controllers/StatusController.php +++ b/src/LaravelEcho/Http/Controllers/StatusController.php @@ -6,7 +6,6 @@ use Illuminate\Http\Request; class StatusController extends EchoController { - public function __invoke(Request $request) { return [ diff --git a/src/LaravelEcho/Pusher/Channels/Channel.php b/src/LaravelEcho/Pusher/Channels/Channel.php index 3d473a5..3ec6ef7 100644 --- a/src/LaravelEcho/Pusher/Channels/Channel.php +++ b/src/LaravelEcho/Pusher/Channels/Channel.php @@ -10,7 +10,7 @@ class Channel /** @var string */ protected $channelId; - /** @var ConnectionInterface[] */ + /** @var \Ratchet\ConnectionInterface[] */ protected $connections = []; public function __construct(string $channelId) @@ -23,17 +23,13 @@ class Channel return count($this->connections) > 0; } - /** + /* * @link https://pusher.com/docs/pusher_protocol#presence-channel-events - * - * @param ConnectionInterface $connection - * @param $payload */ - public function subscribe(ConnectionInterface $connection, $payload) + public function subscribe(ConnectionInterface $connection) { $this->saveConnection($connection); - // Send the success event $connection->send(json_encode([ 'event' => 'pusher_internal:subscription_succeeded', 'channel' => $this->channelId @@ -45,9 +41,9 @@ class Channel unset($this->connections[$connection->socketId]); } - protected function saveConnection(ConnectionInterface $conn) + protected function saveConnection(ConnectionInterface $connection) { - $this->connections[$conn->socketId] = $conn; + $this->connections[$connection->socketId] = $connection; } public function broadcast($payload) @@ -57,10 +53,10 @@ class Channel } } - public function broadcastToOthers($conn, $payload) + public function broadcastToOthers(ConnectionInterface $connection, $payload) { - Collection::make($this->connections)->reject(function ($connection) use ($conn) { - return $connection->socketId === $conn->socketId; + Collection::make($this->connections)->reject(function ($connection) use ($connection) { + return $connection->socketId === $connection->socketId; })->each->send(json_encode($payload)); } } \ No newline at end of file