Fix race between setState and PeerConnection events.

This commit is contained in:
aforge
2023-01-09 20:23:26 -08:00
parent 255e7fda98
commit 54d6719307
7 changed files with 218 additions and 217 deletions
+6 -5
View File
@@ -272,15 +272,16 @@ class CallPanel extends React.PureComponent {
return this.isOutgoingCall || this.state.callInitialSetupComplete;
}
handleNegotiationNeededEvent() {
handleNegotiationNeededEvent(event) {
const pc = event.target;
if (!this.canSendOffer()) {
return;
}
this.state.pc.createOffer().then(offer => {
return this.state.pc.setLocalDescription(offer);
pc.createOffer().then(offer => {
return pc.setLocalDescription(offer);
})
.then(_ => {
this.props.onSendOffer(this.props.topic, this.props.seq, this.state.pc.localDescription.toJSON());
this.props.onSendOffer(this.props.topic, this.props.seq, pc.localDescription.toJSON());
})
.catch(this.reportError);
}
@@ -323,7 +324,7 @@ class CallPanel extends React.PureComponent {
}
handleSignalingStateChangeEvent(event) {
if (this.state.pc.signalingState == 'closed') {
if (event.target.signalingState == 'closed') {
this.handleCloseClick();
}
}