diff --git a/src/WebSockets/Channels/Channel.php b/src/WebSockets/Channels/Channel.php index 39da03c..757f965 100644 --- a/src/WebSockets/Channels/Channel.php +++ b/src/WebSockets/Channels/Channel.php @@ -18,7 +18,7 @@ class Channel public function __construct(string $channelName) { - $this->channelId = $channelName; + $this->channelName = $channelName; } public function hasConnections(): bool @@ -33,7 +33,7 @@ class Channel protected function verifySignature(ConnectionInterface $connection, stdClass $payload) { - $signature = "{$connection->socketId}:{$this->channelId}"; + $signature = "{$connection->socketId}:{$this->channelName}"; if (isset($payload->channel_data)) { $signature .= ":{$payload->channel_data}"; @@ -53,7 +53,7 @@ class Channel $connection->send(json_encode([ 'event' => 'pusher_internal:subscription_succeeded', - 'channel' => $this->channelId + 'channel' => $this->channelName ])); } @@ -62,7 +62,7 @@ class Channel unset($this->subscriptions[$connection->socketId]); if (! $this->hasConnections()) { - DashboardLogger::vacated($connection, $this->channelId); + DashboardLogger::vacated($connection, $this->channelName); } } @@ -73,10 +73,10 @@ class Channel $this->subscriptions[$connection->socketId] = $connection; if (! $hadConnectionsPreviously) { - DashboardLogger::occupied($connection, $this->channelId); + DashboardLogger::occupied($connection, $this->channelName); } - DashboardLogger::subscribed($connection, $this->channelId); + DashboardLogger::subscribed($connection, $this->channelName); } public function broadcast($payload) diff --git a/src/WebSockets/Channels/ChannelManager.php b/src/WebSockets/Channels/ChannelManager.php index 05a2755..e87d3c9 100644 --- a/src/WebSockets/Channels/ChannelManager.php +++ b/src/WebSockets/Channels/ChannelManager.php @@ -12,17 +12,17 @@ class ChannelManager /** @var array */ protected $channels = []; - public function findOrCreate(string $appId, string $channelName): Channel - { - if (!isset($this->channels[$appId][$channelName])) { - $channelClass = $this->determineChannelClass($channelName); +public function findOrCreate(string $appId, string $channelName): Channel +{ + if (!isset($this->channels[$appId][$channelName])) { + $channelClass = $this->determineChannelClass($channelName); - $this->channels[$appId][$channelName] = new $channelClass($channelName); - } - - return $this->channels[$appId][$channelName]; + $this->channels[$appId][$channelName] = new $channelClass($channelName); } + return $this->channels[$appId][$channelName]; +} + public function find(string $appId, string $channelName): ?Channel { return $this->channels[$appId][$channelName] ?? null; diff --git a/src/WebSockets/Channels/PresenceChannel.php b/src/WebSockets/Channels/PresenceChannel.php index d4bf9c0..3d686c7 100644 --- a/src/WebSockets/Channels/PresenceChannel.php +++ b/src/WebSockets/Channels/PresenceChannel.php @@ -29,13 +29,13 @@ class PresenceChannel extends Channel // Send the success event $connection->send(json_encode([ 'event' => 'pusher_internal:subscription_succeeded', - 'channel' => $this->channelId, + 'channel' => $this->channelName, 'data' => json_encode($this->getChannelData()) ])); $this->broadcastToOthers($connection, [ 'event' => 'pusher_internal:member_added', - 'channel' => $this->channelId, + 'channel' => $this->channelName, 'data' => json_encode($channelData) ]); } @@ -46,7 +46,7 @@ class PresenceChannel extends Channel $this->broadcastToOthers($connection, [ 'event' => 'pusher_internal:member_removed', - 'channel' => $this->channelId, + 'channel' => $this->channelName, 'data' => json_encode([ 'user_id' => $this->users[$connection->socketId]->user_id ])