From 41dfe61afd0d93bde88c585332644f4ea92ad627 Mon Sep 17 00:00:00 2001 From: David Westgate Date: Fri, 25 Apr 2025 21:44:07 -0700 Subject: [PATCH] auto restart --- src/static/js/video.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/static/js/video.ts b/src/static/js/video.ts index e28e11c..fe11b07 100644 --- a/src/static/js/video.ts +++ b/src/static/js/video.ts @@ -65,12 +65,23 @@ dataChannel.onclose = () => { console.log("📴 Client: Data channel closed"); }; +const restartIce = (pc, ws) => { + setInterval(async () => { + const offer = await pc.createOffer({ iceRestart: true }); + await pc.setLocalDescription(offer); + ws.send(JSON.stringify({ type: 'offer', data: offer })); + }, 50000) +} + ws0.onopen = async () => { pc0.addTransceiver('video', { direction: 'recvonly' }); pc0.addTransceiver('audio', { direction: 'recvonly' }) const offer = await pc0.createOffer(); await pc0.setLocalDescription(offer); ws0.send(JSON.stringify({ type: 'offer', data: offer })); + if (isSecure) { + restartIce(pc0,ws0); + } } ws0.onmessage = async (message) => {