diff options
author | David Baker <dbkr@matrix.org> | 2014-09-10 11:12:02 +0100 |
---|---|---|
committer | David Baker <dbkr@matrix.org> | 2014-09-10 11:12:02 +0100 |
commit | 55fe0d8adce870cc665f5e68f9cbfaf36ba2617a (patch) | |
tree | 38fc83d63039c32dd1ee79545d2570f12cf2fd71 /webclient | |
parent | reject calls if there's already a call in progress (diff) | |
download | synapse-55fe0d8adce870cc665f5e68f9cbfaf36ba2617a.tar.xz |
Less buggy rejection of calls when busy
Diffstat (limited to 'webclient')
-rw-r--r-- | webclient/app-controller.js | 19 | ||||
-rw-r--r-- | webclient/components/matrix/matrix-call.js | 14 |
2 files changed, 20 insertions, 13 deletions
diff --git a/webclient/app-controller.js b/webclient/app-controller.js index f8a0d8d35c..55397ed216 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -134,6 +134,7 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even if ($rootScope.currentCall && $rootScope.currentCall.state != 'ended') { console.trace("rejecting call because we're already in a call"); call.hangup(); + return; } call.onError = $scope.onCallError; call.onHangup = $scope.onCallHangup; @@ -152,13 +153,15 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even $scope.feedback = errStr; } - $rootScope.onCallHangup = function() { - $timeout(function() { - var icon = angular.element('#callEndedIcon'); - $animate.addClass(icon, 'callIconRotate'); - $timeout(function(){ - $rootScope.currentCall = undefined; - }, 4070); - }, 100); + $rootScope.onCallHangup = function(call) { + if (call == $rootScope.currentCall) { + $timeout(function() { + var icon = angular.element('#callEndedIcon'); + $animate.addClass(icon, 'callIconRotate'); + $timeout(function(){ + $rootScope.currentCall = undefined; + }, 4070); + }, 100); + } } }]); diff --git a/webclient/components/matrix/matrix-call.js b/webclient/components/matrix/matrix-call.js index feb113f60d..68bde78862 100644 --- a/webclient/components/matrix/matrix-call.js +++ b/webclient/components/matrix/matrix-call.js @@ -114,7 +114,7 @@ angular.module('MatrixCall', []) }; matrixService.sendEvent(this.room_id, 'm.call.hangup', undefined, content).then(this.messageSent, this.messageSendFailed); this.state = 'ended'; - self.onHangup(); + if (self.onHangup) self.onHangup(self); }; MatrixCall.prototype.gotUserMediaForInvite = function(stream) { @@ -178,6 +178,10 @@ angular.module('MatrixCall', []) MatrixCall.prototype.gotRemoteIceCandidate = function(cand) { console.trace("Got ICE candidate from remote: "+cand); + if (this.state == 'ended') { + console.trace("Ignoring remote ICE candidate because call has ended"); + return; + } var candidateObject = new RTCIceCandidate({ sdpMLineIndex: cand.label, candidate: cand.candidate @@ -294,10 +298,10 @@ angular.module('MatrixCall', []) self = this; $rootScope.$apply(function() { self.state = 'ended'; - this.hangupParty = 'remote'; + self.hangupParty = 'remote'; self.stopAllMedia(); - this.peerConn.close(); - self.onHangup(); + if (self.peerConn.signalingState != 'closed') self.peerConn.close(); + if (self.onHangup) self.onHangup(self); }); }; @@ -313,7 +317,7 @@ angular.module('MatrixCall', []) this.hangupParty = 'remote'; this.stopAllMedia(); this.peerConn.close(); - this.onHangup(); + if (this.onHangup) this.onHangup(self); }; return MatrixCall; |