Permalink
Switch branches/tags
Nothing to show
Find file Copy path
9ce2cc3 Dec 4, 2018
2 contributors

Users who have contributed to this file

@mpociot @freekmurze
37 lines (28 sloc) 1.1 KB
<?php
namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers;
use Illuminate\Http\Request;
use BeyondCode\LaravelWebSockets\Facades\StatisticsLogger;
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
class TriggerEventController extends Controller
{
public function __invoke(Request $request)
{
$this->ensureValidSignature($request);
foreach ($request->json()->get('channels', []) as $channelName) {
$channel = $this->channelManager->find($request->appId, $channelName);
optional($channel)->broadcastToEveryoneExcept([
'channel' => $channelName,
'event' => $request->json()->get('name'),
'data' => $request->json()->get('data'),
], $request->json()->get('socket_id'));
DashboardLogger::apiMessage(
$request->appId,
$channelName,
$request->json()->get('name'),
$request->json()->get('data')
);
StatisticsLogger::apiMessage($request->appId);
}
return $request->json()->all();
}
}