Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix temporary call messages being handled without call #1834

Merged
merged 5 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/webrtc/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ export class MatrixCall extends EventEmitter {
// https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Perfect_negotiation
const offerCollision = (
(description.type === 'offer') &&
(this.makingOffer || this.peerConn.signalingState != 'stable')
(this.makingOffer || this.peerConn.signalingState !== 'stable')
);

this.ignoreOffer = !polite && offerCollision;
Expand Down Expand Up @@ -1935,6 +1935,10 @@ export class MatrixCall extends EventEmitter {
}
}
}

public get hasPeerConnection() {
return Boolean(this.peerConn);
}
}

async function getScreensharingStream(
Expand Down
10 changes: 8 additions & 2 deletions src/webrtc/callEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export class CallEventHandler {
} else {
this.client.emit("Call.incoming", call);
}
return;
} else if (type === EventType.CallCandidates) {
if (weSentTheEvent) return;

Expand All @@ -232,6 +233,7 @@ export class CallEventHandler {
} else {
call.onRemoteIceCandidatesReceived(event);
}
return;
} else if ([EventType.CallHangup, EventType.CallReject].includes(type)) {
// Note that we also observe our own hangups here so we can see
// if we've already rejected a call that would otherwise be valid
Expand All @@ -255,10 +257,14 @@ export class CallEventHandler {
this.calls.delete(content.call_id);
}
}
return;
}

// The following events need a call
if (!call) return;
// The following events need a call and a peer connection
if (!call || !call.hasPeerConnection) {
logger.warn("Discarding an event, we don't have a call/peerConn", type);
return;
}
// Ignore remote echo
if (event.getContent().party_id === call.ourPartyId) return;

Expand Down