From c8054f80bae84fee7e9586b35df037e7d590cccc Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Thu, 22 Nov 2018 00:03:13 +0100 Subject: [PATCH] wip --- src/LaravelEcho/Pusher/Channels/Channel.php | 8 ++++---- .../Pusher/Channels/PresenceChannel.php | 14 +++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/LaravelEcho/Pusher/Channels/Channel.php b/src/LaravelEcho/Pusher/Channels/Channel.php index e095c72..3d473a5 100644 --- a/src/LaravelEcho/Pusher/Channels/Channel.php +++ b/src/LaravelEcho/Pusher/Channels/Channel.php @@ -26,15 +26,15 @@ class Channel /** * @link https://pusher.com/docs/pusher_protocol#presence-channel-events * - * @param ConnectionInterface $conn + * @param ConnectionInterface $connection * @param $payload */ - public function subscribe(ConnectionInterface $conn, $payload) + public function subscribe(ConnectionInterface $connection, $payload) { - $this->saveConnection($conn); + $this->saveConnection($connection); // Send the success event - $conn->send(json_encode([ + $connection->send(json_encode([ 'event' => 'pusher_internal:subscription_succeeded', 'channel' => $this->channelId ])); diff --git a/src/LaravelEcho/Pusher/Channels/PresenceChannel.php b/src/LaravelEcho/Pusher/Channels/PresenceChannel.php index 233737d..d8f766b 100644 --- a/src/LaravelEcho/Pusher/Channels/PresenceChannel.php +++ b/src/LaravelEcho/Pusher/Channels/PresenceChannel.php @@ -11,24 +11,28 @@ class PresenceChannel extends Channel /** * @link https://pusher.com/docs/pusher_protocol#presence-channel-events * - * @param ConnectionInterface $conn + * @param ConnectionInterface $connection * @param $payload */ - public function subscribe(ConnectionInterface $conn, $payload) + public function subscribe(ConnectionInterface $connection, $payload) { - $this->saveConnection($conn); + $this->saveConnection($connection); $channelData = json_decode($payload->channel_data); $this->subscriptions[$channelData->user_id] = $channelData; // Send the success event - $conn->send(json_encode([ + $connection->send(json_encode([ 'event' => 'pusher_internal:subscription_succeeded', 'channel' => $this->channelId, 'data' => json_encode($this->getChannelData()) ])); - //TODO: send member_added message back to client, and broadcast to everyone on channel + $this->broadcastToOthers($connection, [ + 'event' => 'pusher_internal:member_added', + 'channel' => $this->channelId, + 'data' => json_encode($channelData) + ]); } public function unsubscribe(ConnectionInterface $connection)