-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* close with message * ensure app exists * handle event trigger * scaffold routes * implement events controller * update phpunit config * implement batch events endpoint * implement channels route * wip * add channels test * use correct id * wip * revert * add channel endpoint * Fix code styling * implements users routes * implement terminate user endpoint * formatting
- Loading branch information
Showing
29 changed files
with
835 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
<php> | ||
<env name="APP_KEY" value="base64:uz4B1RtFO57QGzbZX1kRYX9hIRB50+QzqFeg9zbFJlY="/> | ||
<env name="PUSHER_APP_ID" value="123456"/> | ||
<env name="PUSHER_APP_KEY" value="pusher-key"/> | ||
<env name="PUSHER_APP_SECRET" value="pusher-secret"/> | ||
<env name="REVERB_API_GATEWAY_CONNECTION_CACHE" value="redis"/> | ||
</php> | ||
</phpunit> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage/> | ||
<php> | ||
<env name="APP_KEY" value="base64:uz4B1RtFO57QGzbZX1kRYX9hIRB50+QzqFeg9zbFJlY="/> | ||
<env name="PUSHER_APP_ID" value="123456"/> | ||
<env name="PUSHER_APP_KEY" value="pusher-key"/> | ||
<env name="PUSHER_APP_SECRET" value="pusher-secret"/> | ||
<env name="REVERB_API_GATEWAY_CONNECTION_CACHE" value="redis"/> | ||
</php> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Laravel\Reverb\Pusher\Http\Controllers; | ||
|
||
use Laravel\Reverb\Channels\ChannelBroker; | ||
use Laravel\Reverb\Http\Connection; | ||
use Psr\Http\Message\RequestInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class ChannelController extends Controller | ||
{ | ||
/** | ||
* Handle the request. | ||
*/ | ||
public function handle(RequestInterface $request, Connection $connection, ...$args): Response | ||
{ | ||
$info = explode(',', $this->query['info'] ?? ''); | ||
$connections = $this->channels->channel(ChannelBroker::create($args['channel'])); | ||
$totalConnections = count($connections); | ||
|
||
return new JsonResponse((object) array_filter([ | ||
'occupied' => $totalConnections > 0, | ||
'user_count' => in_array('user_count', $info) ? $totalConnections : null, | ||
'subscription_count' => in_array('subscription_count', $info) ? $totalConnections : null, | ||
'cache' => in_array('cache', $info) ? '{}' : null, | ||
], fn ($item) => $item !== null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Laravel\Reverb\Pusher\Http\Controllers; | ||
|
||
use Laravel\Reverb\Channels\ChannelBroker; | ||
use Laravel\Reverb\Channels\PresenceChannel; | ||
use Laravel\Reverb\Http\Connection; | ||
use Psr\Http\Message\RequestInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class ChannelUsersController extends Controller | ||
{ | ||
/** | ||
* Handle the request. | ||
*/ | ||
public function handle(RequestInterface $request, Connection $connection, ...$args): Response | ||
{ | ||
$channel = ChannelBroker::create($args['channel']); | ||
|
||
if (! $channel instanceof PresenceChannel) { | ||
return new JsonResponse((object) [], 400); | ||
} | ||
|
||
return new JsonResponse((object) []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Laravel\Reverb\Pusher\Http\Controllers; | ||
|
||
use Illuminate\Support\Str; | ||
use Laravel\Reverb\Http\Connection; | ||
use Psr\Http\Message\RequestInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class ChannelsController extends Controller | ||
{ | ||
/** | ||
* Handle the request. | ||
*/ | ||
public function handle(RequestInterface $request, Connection $connection, ...$args): Response | ||
{ | ||
$channels = $this->channels->channels(); | ||
$info = explode(',', $this->query['info'] ?? ''); | ||
|
||
if (isset($this->query['filter_by_prefix'])) { | ||
$channels = $channels->filter(fn ($connections, $name) => Str::startsWith($name, $this->query['filter_by_prefix'])); | ||
} | ||
|
||
$channels = $channels->mapWithKeys(function ($connections, $name) use ($info) { | ||
return [$name => array_filter(['user_count' => in_array('user_count', $info) ? count($connections) : null])]; | ||
}); | ||
|
||
return new JsonResponse((object) ['channels' => $channels]); | ||
} | ||
} |
Oops, something went wrong.