mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-12 03:54:19 -05:00
Always pick the incoming call if we've not yet sent out our invite, otherwise the remorte party will see their call get rejected and our call won't come in until our user clicks allow.
This commit is contained in:
parent
a81ec21762
commit
8b28f7d14e
@ -203,6 +203,12 @@ angular.module('MatrixCall', [])
|
|||||||
|
|
||||||
MatrixCall.prototype.gotLocalOffer = function(description) {
|
MatrixCall.prototype.gotLocalOffer = function(description) {
|
||||||
console.log("Created offer: "+description);
|
console.log("Created offer: "+description);
|
||||||
|
|
||||||
|
if (this.state == 'ended') {
|
||||||
|
console.log("Ignoring newly created offer on call ID "+this.call_id+" because the call has ended");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.peerConn.setLocalDescription(description);
|
this.peerConn.setLocalDescription(description);
|
||||||
|
|
||||||
var content = {
|
var content = {
|
||||||
|
@ -48,21 +48,24 @@ angular.module('matrixPhoneService', [])
|
|||||||
var thisCall = matrixPhoneService.allCalls[thisCallId];
|
var thisCall = matrixPhoneService.allCalls[thisCallId];
|
||||||
|
|
||||||
if (call.room_id == thisCall.room_id && thisCall.direction == 'outbound'
|
if (call.room_id == thisCall.room_id && thisCall.direction == 'outbound'
|
||||||
&& (thisCall.state == 'wait_local_media' || thisCall.state == 'invite_sent' || thisCall.state == 'create_offer')) {
|
&& (thisCall.state == 'wait_local_media' || thisCall.state == 'create_offer' || thisCall.state == 'invite_sent')) {
|
||||||
existingCall = thisCall;
|
existingCall = thisCall;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingCall) {
|
if (existingCall) {
|
||||||
if (existingCall.call_id < call.call_id) {
|
// If we've only got to wait_local_media or create_offer and we've got an invite,
|
||||||
console.log("Glare detected: rejecting incoming call "+call.call_id+" and keeping outgoing call "+existingCall.call_id);
|
// pick the incoming call because we know we haven't sent our invite yet
|
||||||
call.hangup();
|
// otherwise, pick whichever call has the lowest call ID (by string comparison)
|
||||||
} else {
|
if (existingCall.state == 'wait_local_media' || existingCall.state == 'create_offer' || existingCall.call_id > call.call_id) {
|
||||||
console.log("Glare detected: answering incoming call "+call.call_id+" and canceling outgoing call "+existingCall.call_id);
|
console.log("Glare detected: answering incoming call "+call.call_id+" and canceling outgoing call "+existingCall.call_id);
|
||||||
existingCall.replacedBy(call);
|
existingCall.replacedBy(call);
|
||||||
call.answer();
|
call.answer();
|
||||||
$rootScope.$broadcast(matrixPhoneService.REPLACED_CALL_EVENT, existingCall, call);
|
$rootScope.$broadcast(matrixPhoneService.REPLACED_CALL_EVENT, existingCall, call);
|
||||||
|
} else {
|
||||||
|
console.log("Glare detected: rejecting incoming call "+call.call_id+" and keeping outgoing call "+existingCall.call_id);
|
||||||
|
call.hangup();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$rootScope.$broadcast(matrixPhoneService.INCOMING_CALL_EVENT, call);
|
$rootScope.$broadcast(matrixPhoneService.INCOMING_CALL_EVENT, call);
|
||||||
|
Loading…
Reference in New Issue
Block a user