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