From 13a56171daf9e9edceafff49ef4434630ca89d26 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Mon, 6 Nov 2023 09:45:32 +0000 Subject: [PATCH] get stats per app --- src/Http/Controllers/StatsController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Http/Controllers/StatsController.php b/src/Http/Controllers/StatsController.php index 2ee21774..b8845955 100644 --- a/src/Http/Controllers/StatsController.php +++ b/src/Http/Controllers/StatsController.php @@ -3,6 +3,7 @@ namespace Laravel\Reverb\Http\Controllers; use Illuminate\Support\Facades\App; +use Laravel\Reverb\Contracts\ApplicationProvider; use Laravel\Reverb\Contracts\ChannelManager; use Laravel\Reverb\Contracts\ConnectionManager; use Psr\Http\Message\RequestInterface; @@ -14,9 +15,12 @@ class StatsController implements HttpServerInterface { public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) { + parse_str($request->getUri()->getQuery(), $queryString); + $app = App::make(ApplicationProvider::class)->findById($queryString['appId']); + tap($conn)->send(new JsonResponse((object) [ - 'connections' => App::make(ConnectionManager::class)->all()->count(), - 'channels' => App::make(ChannelManager::class)->all()->map(function ($channel) { + 'connections' => App::make(ConnectionManager::class)->for($app)->all()->count(), + 'channels' => App::make(ChannelManager::class)->for($app)->all()->map(function ($channel) { return [ 'name' => $channel->name(), 'connections' => App::make(ChannelManager::class)