diff options
author | David Baker <dbkr@matrix.org> | 2014-09-12 14:06:35 +0100 |
---|---|---|
committer | David Baker <dbkr@matrix.org> | 2014-09-12 14:06:35 +0100 |
commit | 8b28f7d14eada611a9c70609ac7499307cdd07ba (patch) | |
tree | e80f88e3003110aecf72305f42914ccb4b1f680a /webclient | |
parent | Remove the local AV stream from ourselves when handing it off to a new call o... (diff) | |
download | synapse-8b28f7d14eada611a9c70609ac7499307cdd07ba.tar.xz |
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.
Diffstat (limited to 'webclient')
-rw-r--r-- | webclient/components/matrix/matrix-call.js | 6 | ||||
-rw-r--r-- | webclient/components/matrix/matrix-phone-service.js | 13 |
2 files changed, 14 insertions, 5 deletions
diff --git a/webclient/components/matrix/matrix-call.js b/webclient/components/matrix/matrix-call.js index e402e02d33..f8aaf94947 100644 --- a/webclient/components/matrix/matrix-call.js +++ b/webclient/components/matrix/matrix-call.js @@ -203,6 +203,12 @@ angular.module('MatrixCall', []) MatrixCall.prototype.gotLocalOffer = function(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); var content = { diff --git a/webclient/components/matrix/matrix-phone-service.js b/webclient/components/matrix/matrix-phone-service.js index 26be4bf2ad..b0dcf19100 100644 --- a/webclient/components/matrix/matrix-phone-service.js +++ b/webclient/components/matrix/matrix-phone-service.js @@ -48,21 +48,24 @@ angular.module('matrixPhoneService', []) var thisCall = matrixPhoneService.allCalls[thisCallId]; 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; break; } } if (existingCall) { - if (existingCall.call_id < call.call_id) { - console.log("Glare detected: rejecting incoming call "+call.call_id+" and keeping outgoing call "+existingCall.call_id); - call.hangup(); - } else { + // If we've only got to wait_local_media or create_offer and we've got an invite, + // pick the incoming call because we know we haven't sent our invite yet + // otherwise, pick whichever call has the lowest call ID (by string comparison) + 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); existingCall.replacedBy(call); call.answer(); $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 { $rootScope.$broadcast(matrixPhoneService.INCOMING_CALL_EVENT, call); |