2018-12-03 11:12:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace BeyondCode\LaravelWebSockets\Statistics\Http\Controllers;
|
|
|
|
|
|
2020-08-18 18:22:29 +00:00
|
|
|
use BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver;
|
2018-12-04 21:22:33 +00:00
|
|
|
use BeyondCode\LaravelWebSockets\Statistics\Events\StatisticsUpdated;
|
2020-03-04 09:58:39 +00:00
|
|
|
use BeyondCode\LaravelWebSockets\Statistics\Rules\AppId;
|
|
|
|
|
use Illuminate\Http\Request;
|
2018-12-03 11:12:53 +00:00
|
|
|
|
2018-12-03 22:19:46 +00:00
|
|
|
class WebSocketStatisticsEntriesController
|
2018-12-03 11:12:53 +00:00
|
|
|
{
|
2020-08-18 17:21:22 +00:00
|
|
|
/**
|
|
|
|
|
* Store the entry.
|
|
|
|
|
*
|
|
|
|
|
* @param \Illuminate\Http\Request $request
|
2020-08-18 18:22:29 +00:00
|
|
|
* @param \BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver $driver
|
2020-08-18 17:21:22 +00:00
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
2020-08-18 18:22:29 +00:00
|
|
|
public function store(Request $request, StatisticsDriver $driver)
|
2018-12-03 11:12:53 +00:00
|
|
|
{
|
|
|
|
|
$validatedAttributes = $request->validate([
|
2018-12-03 12:33:00 +00:00
|
|
|
'app_id' => ['required', new AppId()],
|
2018-12-03 13:35:00 +00:00
|
|
|
'peak_connection_count' => 'required|integer',
|
2018-12-03 11:12:53 +00:00
|
|
|
'websocket_message_count' => 'required|integer',
|
|
|
|
|
'api_message_count' => 'required|integer',
|
|
|
|
|
]);
|
|
|
|
|
|
2020-08-18 18:22:29 +00:00
|
|
|
broadcast(new StatisticsUpdated(
|
|
|
|
|
$driver::create($validatedAttributes)
|
|
|
|
|
));
|
2018-12-03 12:05:54 +00:00
|
|
|
|
|
|
|
|
return 'ok';
|
2018-12-03 11:12:53 +00:00
|
|
|
}
|
2018-12-04 21:22:33 +00:00
|
|
|
}
|