Skip to content

Commit

Permalink
Fixed issue #7 and add support broadcast()->toOthers()
Browse files Browse the repository at this point in the history
  • Loading branch information
stenin-nikita committed Apr 9, 2017
1 parent 672b498 commit 9c6d56b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/CentrifugeBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9c6d56b

Please sign in to comment.