<?phpnamespace App\Net;use JumPHP\WebRtc\WebRtc;/** Which WebRTC this computer has; without one, the simulated backend (LocalBackend) so the screens of this game still work. */final class Rtc{ /** 'browser', 'native' or 'simulated' */ public static function prepare(WebRtc $webrtc): string { if (!$webrtc->isSupported()) { $webrtc->setBackend(new LocalBackend()); } return $webrtc->backendName(); } /** Can this computer reach another one (online play)? Not with the simulation. */ public static function real(WebRtc $webrtc): bool { return self::prepare($webrtc) !== 'simulated'; } /** The backend in words (a key of lang.yaml). */ public static function describe(string $backend): string { return match ($backend) { 'browser' => 'the browser (RTCPeerConnection)', 'native' => 'this computer (GStreamer)', default => 'simulated (no WebRTC on this computer)', }; }}