diff --git a/decs.d.ts b/decs.d.ts index 8c8f84cd..3de73779 100644 --- a/decs.d.ts +++ b/decs.d.ts @@ -328,6 +328,7 @@ interface RTCPeerConnection extends EventTarget { readonly signalingState: RTCSignalingState; readonly connectionState: RTCPeerConnectionState; + restartIce(): void; getConfiguration(): RTCConfiguration; setConfiguration(configuration: RTCConfiguration): void; close(): void; diff --git a/package.json b/package.json index 207bc39a..741d506a 100644 --- a/package.json +++ b/package.json @@ -58,4 +58,4 @@ "ion", "js" ] -} \ No newline at end of file +} diff --git a/src/client.ts b/src/client.ts index cb4f2e6b..f76eca76 100644 --- a/src/client.ts +++ b/src/client.ts @@ -47,7 +47,16 @@ export class Transport { this.signal.trickle({ target: role, candidate }); } }; - } + + this.pc.oniceconnectionstatechange = async (e) => { + if (this.pc.iceConnectionState === "disconnected") { + if (this.pc.restartIce) { + // this will trigger onNegotiationNeeded + this.pc.restartIce(); + } + } + } + }; } export default class Client {