From 9c6d56b097cdca60870e12df17d8abf4158ce4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BD=D0=B8=D0=BD=20=D0=9D=D0=B8=D0=BA?= =?UTF-8?q?=D0=B8=D1=82=D0=B0?= Date: Sun, 9 Apr 2017 21:52:16 +0500 Subject: [PATCH] Fixed issue #7 and add support broadcast()->toOthers() --- src/CentrifugeBroadcaster.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CentrifugeBroadcaster.php b/src/CentrifugeBroadcaster.php index b124375..5854f93 100644 --- a/src/CentrifugeBroadcaster.php +++ b/src/CentrifugeBroadcaster.php @@ -43,8 +43,10 @@ public function auth($request) $response = []; $info = json_encode([]); foreach ($channels as $channel) { + $channelName = (substr($channel, 0, 1) === '$') ? substr($channel, 1) : $channel; + try { - $result = $this->verifyUserCanAccessChannel($request, $channel); + $result = $this->verifyUserCanAccessChannel($request, $channelName); } catch (HttpException $e) { $result = false; } @@ -87,7 +89,13 @@ public function broadcast(array $channels, $event, array $payload = []) { $payload['event'] = $event; - $response = $this->centrifuge->broadcast($this->formatChannels($channels), $payload); + $socket = null; + if(array_key_exists('socket', $payload)) { + $socket = $payload['socket']; + unset($payload['socket']); + } + + $response = $this->centrifuge->broadcast($this->formatChannels($channels), $payload, $socket); if (is_array($response) && is_null($response['error'])) { return;