using System.Threading.Tasks; using UnityEngine; namespace IDCGames.API { /// /// Hook LiveKit Unity SDK here after JoinMatchAsync returns voice.url + voice.token. /// 1. await GetVoiceConfigAsync() and enforce client_requirements.vad.required. /// 2. Room.Connect(url, token) — gate mic publish until VAD opens (no silent uplink). /// Package: https://docs.livekit.io/home/client/connect/ /// public class IDCMatchVoiceLiveKitBridge : MonoBehaviour { public IDCMatchVoiceManager matchVoice; [Tooltip("Simulated VAD gate — replace with your audio pipeline")] public bool vadGateOpen; /// Call with credentials from MatchJoinResult.voice (provider livekit). public Task ConnectLiveKitAsync(MatchJoinVoice credentials) { if (credentials == null || string.IsNullOrEmpty(credentials.token)) { Debug.LogWarning("LiveKit: voice disabled or missing token"); return Task.CompletedTask; } if (!vadGateOpen) { Debug.Log( "LiveKit: VAD gate closed — do not publish audio until player speaks (see voice config API)."); } // Example with LiveKit SDK (add package to project): // var room = new LiveKit.Room(); // await room.Connect(credentials.url, credentials.token); // Only call SetMicrophoneEnabled(true) / publish when vadGateOpen is true. Debug.Log($"LiveKit ready: room={credentials.room_name} url={credentials.url}"); return Task.CompletedTask; } } }