diff --git a/src/LaravelEcho/Pusher/Channels/Channel.php b/src/LaravelEcho/Pusher/Channels/Channel.php index cf654c1..d84ea03 100644 --- a/src/LaravelEcho/Pusher/Channels/Channel.php +++ b/src/LaravelEcho/Pusher/Channels/Channel.php @@ -35,8 +35,7 @@ class Channel $signature .= ":{$payload->channel_data}"; } - // TODO Have app id specific secrets - if (str_after($auth, ':') !== hash_hmac('sha256', $signature, config('broadcasting.connections.pusher.secret'))) { + if (str_after($auth, ':') !== hash_hmac('sha256', $signature, $connection->client->appSecret)) { throw new InvalidSignatureException(); } } diff --git a/src/LaravelEcho/Pusher/Channels/ChannelManager.php b/src/LaravelEcho/Pusher/Channels/ChannelManager.php index c4f7233..2b2c46b 100644 --- a/src/LaravelEcho/Pusher/Channels/ChannelManager.php +++ b/src/LaravelEcho/Pusher/Channels/ChannelManager.php @@ -47,16 +47,16 @@ class ChannelManager public function removeFromAllChannels(ConnectionInterface $connection) { - collect($this->channels[$connection->appId])->each->unsubscribe($connection); + collect($this->channels[$connection->client->appId])->each->unsubscribe($connection); - collect($this->channels[$connection->appId]) + collect($this->channels[$connection->client->appId]) ->reject->hasConnections() ->each(function (Channel $channel, string $channelId) use ($connection) { - unset($this->channels[$connection->appId][$channelId]); + unset($this->channels[$connection->client->appId][$channelId]); }); - if (count($this->channels[$connection->appId]) === 0) { - unset($this->channels[$connection->appId]); + if (count($this->channels[$connection->client->appId]) === 0) { + unset($this->channels[$connection->client->appId]); }; } } \ No newline at end of file diff --git a/src/LaravelEcho/Pusher/PusherMessage.php b/src/LaravelEcho/Pusher/PusherMessage.php index 71e7b7b..2ec4855 100644 --- a/src/LaravelEcho/Pusher/PusherMessage.php +++ b/src/LaravelEcho/Pusher/PusherMessage.php @@ -51,14 +51,14 @@ class PusherMessage implements RespondableMessage */ protected function subscribe(ConnectionInterface $connection, stdClass $payload) { - $channel = $this->channelManager->findOrCreate($connection->appId, $payload->channel); + $channel = $this->channelManager->findOrCreate($connection->client->appId, $payload->channel); $channel->subscribe($connection, $payload); } public function unsubscribe(ConnectionInterface $connection, stdClass $payload) { - $channel = $this->channelManager->findOrCreate($connection->appId, $payload->channel); + $channel = $this->channelManager->findOrCreate($connection->client->appId, $payload->channel); $channel->unsubscribe($connection); } diff --git a/src/LaravelEcho/WebSocket/Message.php b/src/LaravelEcho/WebSocket/Message.php index 981dc64..ad089d2 100644 --- a/src/LaravelEcho/WebSocket/Message.php +++ b/src/LaravelEcho/WebSocket/Message.php @@ -29,7 +29,7 @@ class Message implements RespondableMessage public function respond() { if (starts_with($this->payload->event, 'client-')) { - $channel = $this->channelManager->find($this->connection->appId, $this->payload->channel); + $channel = $this->channelManager->find($this->connection->client->appId, $this->payload->channel); optional($channel)->broadcast($this->payload); } diff --git a/src/LaravelEcho/WebSocket/PusherServer.php b/src/LaravelEcho/WebSocket/PusherServer.php index 9caf4cb..f48027f 100644 --- a/src/LaravelEcho/WebSocket/PusherServer.php +++ b/src/LaravelEcho/WebSocket/PusherServer.php @@ -64,7 +64,7 @@ class PusherServer extends WebSocketController throw new UnknownAppKey($queryParameters['appKey']); } - $connection->appId = $client->appId; + $connection->client = $client; } protected function establishConnection(ConnectionInterface $connection) diff --git a/src/Server/Logger/ConnectionLogger.php b/src/Server/Logger/ConnectionLogger.php index a0c3b53..6bcba62 100644 --- a/src/Server/Logger/ConnectionLogger.php +++ b/src/Server/Logger/ConnectionLogger.php @@ -29,14 +29,14 @@ class ConnectionLogger extends Logger implements ConnectionInterface public function send($data) { - $this->info("{$this->connection->appId}: connection id {$this->connection->socketId} sending message {$data}"); + $this->info("{$this->connection->client->appId}: connection id {$this->connection->socketId} sending message {$data}"); $this->connection->send($data); } public function close() { - $this->warn("{$this->connection->appId}: connection id {$this->connection->socketId} closing."); + $this->warn("{$this->connection->client->appId}: connection id {$this->connection->socketId} closing."); $this->connection->close(); } diff --git a/src/Server/Logger/MessageLogger.php b/src/Server/Logger/MessageLogger.php index a463d29..a2c5bce 100644 --- a/src/Server/Logger/MessageLogger.php +++ b/src/Server/Logger/MessageLogger.php @@ -46,14 +46,14 @@ class MessageLogger extends Logger implements MessageComponentInterface public function onMessage(ConnectionInterface $connection, MessageInterface $message) { - $this->info("{$connection->appId}: connection id {$connection->socketId} received message: {$message->getPayload()}."); + $this->info("{$connection->client->appId}: connection id {$connection->socketId} received message: {$message->getPayload()}."); $this->app->onMessage(ConnectionLogger::decorate($connection), $message); } public function onClose(ConnectionInterface $connection) { - $this->warn("{$connection->appId}: connection id {$connection->socketId} closed."); + $this->warn("{$connection->client->appId}: connection id {$connection->socketId} closed."); $this->app->onClose(ConnectionLogger::decorate($connection)); } @@ -62,7 +62,7 @@ class MessageLogger extends Logger implements MessageComponentInterface { $exceptionClass = get_class($exception); - $appId = $connection->appId ?? 'Unknown app id'; + $appId = $connection->client->appId ?? 'Unknown app id'; $message = "{$appId}: exception `{$exceptionClass}` thrown: `{$exception->getMessage()}`";