- Add Metered and ConvexSol (CoTURN) provider drivers with response validation and caching - Add IceCandidateManager with automatic failover and structured logging - Add IceCandidateProviderInterface and DTOs conforming to RTCIceServer format
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Contracts\IceCandidateProviderInterface;
|
|
use App\Http\Resources\Interview\IceCandidatesResource;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class IceServerController extends Controller
|
|
{
|
|
public function __construct(
|
|
protected IceCandidateProviderInterface $iceCandidateProvider
|
|
) {}
|
|
|
|
public function __invoke(): JsonResponse|IceCandidatesResource
|
|
{
|
|
if (! Auth::check() && ! session()->has('candidate_interview_id')) {
|
|
return response()->json(['error' => 'Unauthenticated access.'], 401);
|
|
}
|
|
|
|
try {
|
|
$candidates = $this->iceCandidateProvider->getIceCandidates();
|
|
|
|
return new IceCandidatesResource($candidates);
|
|
} catch (\Throwable $e) {
|
|
Log::error('ICE servers fetch exception: '.$e->getMessage());
|
|
|
|
return response()->json([
|
|
'error' => 'An error occurred while fetching ICE servers.',
|
|
'message' => $e->getMessage(),
|
|
], 500);
|
|
}
|
|
}
|
|
}
|