@yz-social/webrtc 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -169,7 +169,7 @@ export class WebRTC {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
if (description.type === "offer" && this.pc && ['have-remote-offer', 'have-local-pranswer'].includes(this.pc
|
|
172
|
+
if (description.type === "offer" && this.pc && ['have-remote-offer', 'have-local-pranswer'].includes(this.pc?.signalingState)) {
|
|
173
173
|
const answer = await this.pc.createAnswer();
|
|
174
174
|
await this.pc.setLocalDescription(answer)
|
|
175
175
|
.catch(e => this.log(this.name, 'ignoring error setLocalDescription of answer', e));
|
|
@@ -178,13 +178,13 @@ export class WebRTC {
|
|
|
178
178
|
|
|
179
179
|
} else if (candidate) {
|
|
180
180
|
//this.log('add ice');
|
|
181
|
-
if (this.pc
|
|
182
|
-
this.log('icecandidate, connection:', this.pc
|
|
181
|
+
if (this.pc?.connectionState === 'closed' || !this.pc?.remoteDescription?.type) { // Adding ice without a proceessed offer/answer will crash. Log and drop the candidate.
|
|
182
|
+
this.log('icecandidate, connection:', this.pc?.connectionState, 'signaling:', this.pc?.signalingState, 'ice connection:', this.pc?.iceConnectionState, 'gathering:', this.pc?.iceGatheringState);
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
await this.pc.addIceCandidate(candidate)
|
|
186
186
|
.catch(e => {
|
|
187
|
-
if (!this.ignoreOffer && this.pc
|
|
187
|
+
if (!this.ignoreOffer && this.pc?.connectionState !== 'closed') throw e;
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
}
|