diff --git a/src/client.ts b/src/client.ts index 5430bf30..83392c63 100644 --- a/src/client.ts +++ b/src/client.ts @@ -177,6 +177,10 @@ export default class Client { stream.publish(this.transports[Role.pub]); } + restartIce() { + this.renegotiate(true) + } + createDataChannel(label: string) { if (!this.transports) { throw Error(ERR_NO_SESSION); @@ -222,7 +226,11 @@ export default class Client { } } - private async onNegotiationNeeded() { + private onNegotiationNeeded() { + this.renegotiate(false) + } + + private async renegotiate(iceRestart: boolean) { if (!this.transports) { throw Error(ERR_NO_SESSION); } @@ -230,7 +238,7 @@ export default class Client { let offer: RTCSessionDescriptionInit | undefined; let answer: RTCSessionDescriptionInit | undefined; try { - offer = await this.transports[Role.pub].pc.createOffer(); + offer = await this.transports[Role.pub].pc.createOffer({ iceRestart }); await this.transports[Role.pub].pc.setLocalDescription(offer); answer = await this.signal.offer(offer); await this.transports[Role.pub].pc.setRemoteDescription(answer);