From caf0b80acf858f67ec81a8f80eccd4c9f680e5e0 Mon Sep 17 00:00:00 2001 From: kwasniow Date: Thu, 27 Jun 2024 17:21:53 +0200 Subject: [PATCH] feat: expose icecandidateerror event --- src/peer-connection.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/peer-connection.ts b/src/peer-connection.ts index 9529662..0451c2f 100644 --- a/src/peer-connection.ts +++ b/src/peer-connection.ts @@ -28,6 +28,7 @@ type IceGatheringStateChangeEvent = { enum PeerConnectionEvents { IceGatheringStateChange = 'icegatheringstatechange', IceCandidate = 'icecandidate', + IceCandidateError = 'icecandidateerror', PeerConnectionStateChange = 'peerconnectionstatechange', IceConnectionStateChange = 'iceconnectionstatechange', CreateOfferOnSuccess = 'createofferonsuccess', @@ -39,6 +40,7 @@ enum PeerConnectionEvents { interface PeerConnectionEventHandlers extends EventMap { [PeerConnectionEvents.IceGatheringStateChange]: (ev: IceGatheringStateChangeEvent) => void; [PeerConnectionEvents.IceCandidate]: (ev: RTCPeerConnectionIceEvent) => void; + [PeerConnectionEvents.IceCandidateError]: (ev: RTCPeerConnectionIceErrorEvent) => void; [PeerConnectionEvents.PeerConnectionStateChange]: (state: RTCPeerConnectionState) => void; [PeerConnectionEvents.IceConnectionStateChange]: (state: RTCIceConnectionState) => void; [PeerConnectionEvents.CreateOfferOnSuccess]: (offer: RTCSessionDescriptionInit) => void; @@ -113,6 +115,12 @@ class PeerConnection extends EventEmitter { this.pc.onicecandidate = (ev: RTCPeerConnectionIceEvent) => { this.emit(PeerConnection.Events.IceCandidate, ev); }; + + this.pc.onicecandidateerror = (ev: Event) => { + const event = ev as RTCPeerConnectionIceErrorEvent; + + this.emit(PeerConnection.Events.IceCandidateError, event); + }; } /**