wip
This commit is contained in:
parent
86651938ee
commit
8bd50f0e61
|
|
@ -7,6 +7,7 @@ use BeyondCode\LaravelWebSockets\Statistics\Statistic;
|
|||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||
use Clue\React\Buzz\Browser;
|
||||
use GuzzleHttp\Client;
|
||||
use function GuzzleHttp\Psr7\stream_for;
|
||||
use Ratchet\ConnectionInterface;
|
||||
|
||||
class HttpStatisticsLogger implements StatisticsLogger
|
||||
|
|
@ -67,24 +68,17 @@ class HttpStatisticsLogger implements StatisticsLogger
|
|||
echo 'in actual save method';
|
||||
|
||||
foreach ($this->statistics as $appId => $statistic) {
|
||||
echo "stats of ${appId} " . $statistic->isEnabled() ? 'enabled' : 'DISABLED!';
|
||||
|
||||
if (!$statistic->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo 'posted';
|
||||
$this->browser
|
||||
->post(
|
||||
action([WebsocketStatisticsEntriesController::class, 'store']),
|
||||
[],
|
||||
$statistic->toArray()
|
||||
)
|
||||
->then(function() {
|
||||
echo 'fulfilled';
|
||||
}, function($e) {
|
||||
echo 'fulfilled';
|
||||
dd($);
|
||||
});
|
||||
['Content-Type' => 'application/json'],
|
||||
stream_for(json_encode($statistic->toArray()))
|
||||
);
|
||||
|
||||
// Reset connection and message count
|
||||
$currentConnectionCount = collect($this->channelManager->getChannels($appId))
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Route;
|
|||
use BeyondCode\LaravelWebSockets\Apps\AppProvider;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class WebSocketsServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -31,6 +32,8 @@ class WebSocketsServiceProvider extends ServiceProvider
|
|||
|
||||
$this->registerRouteMacro();
|
||||
|
||||
$this->registerStatisticRoute();
|
||||
|
||||
$this->registerDashboardGate();
|
||||
|
||||
$this->loadViewsFrom(__DIR__.'/../resources/views/', 'websockets');
|
||||
|
|
@ -65,11 +68,13 @@ class WebSocketsServiceProvider extends ServiceProvider
|
|||
Route::post('auth', AuthenticateDashboard::class);
|
||||
Route::post('event', SendMessage::class);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//TODO: add middleware
|
||||
Route::prefix($prefix)->namespace('\\')->group(function() {
|
||||
Route::post('statistics', [WebsocketStatisticsEntriesController::class, 'store']);
|
||||
});
|
||||
protected function registerStatisticRoute()
|
||||
{
|
||||
Route::prefix('/laravel-websockets')->namespace('\\')->group(function() {
|
||||
Route::post('statistics', [WebsocketStatisticsEntriesController::class, 'store']);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue