Propagate failure reason to the other party.

This commit is contained in:
David Baker 2014-09-22 11:44:15 +01:00
parent 83ea3c96ec
commit 4696622b0a
2 changed files with 8 additions and 7 deletions

View File

@ -197,7 +197,7 @@ angular.module('MatrixCall', [])
} }
}; };
MatrixCall.prototype.hangup = function(suppressEvent) { MatrixCall.prototype.hangup = function(reason, suppressEvent) {
console.log("Ending call "+this.call_id); console.log("Ending call "+this.call_id);
// pausing now keeps the last frame (ish) of the video call in the video element // pausing now keeps the last frame (ish) of the video call in the video element
@ -209,10 +209,12 @@ angular.module('MatrixCall', [])
if (this.peerConn) this.peerConn.close(); if (this.peerConn) this.peerConn.close();
this.hangupParty = 'local'; this.hangupParty = 'local';
this.hangupReason = reason;
var content = { var content = {
version: 0, version: 0,
call_id: this.call_id, call_id: this.call_id,
reason: reason
}; };
this.sendEventWithRetry('m.call.hangup', content); this.sendEventWithRetry('m.call.hangup', content);
this.state = 'ended'; this.state = 'ended';
@ -324,8 +326,7 @@ angular.module('MatrixCall', [])
var self = this; var self = this;
$timeout(function() { $timeout(function() {
if (self.state == 'invite_sent') { if (self.state == 'invite_sent') {
self.hangupReason = 'invite_timeout'; self.hangup('invite_timeout');
self.hangup();
} }
}, MatrixCall.CALL_TIMEOUT); }, MatrixCall.CALL_TIMEOUT);
@ -369,8 +370,7 @@ angular.module('MatrixCall', [])
self.didConnect = true; self.didConnect = true;
}); });
} else if (this.peerConn.iceConnectionState == 'failed') { } else if (this.peerConn.iceConnectionState == 'failed') {
this.hangupReason = 'ice_failed'; this.hangup('ice_failed');
this.hangup();
} }
}; };
@ -448,12 +448,13 @@ angular.module('MatrixCall', [])
}); });
}; };
MatrixCall.prototype.onHangupReceived = function() { MatrixCall.prototype.onHangupReceived = function(msg) {
console.log("Hangup received"); console.log("Hangup received");
if (this.remoteVideoElement) this.remoteVideoElement.pause(); if (this.remoteVideoElement) this.remoteVideoElement.pause();
if (this.localVideoElement) this.localVideoElement.pause(); if (this.localVideoElement) this.localVideoElement.pause();
this.state = 'ended'; this.state = 'ended';
this.hangupParty = 'remote'; this.hangupParty = 'remote';
this.hangupReason = msg.reason;
this.stopAllMedia(); this.stopAllMedia();
if (this.peerConn && this.peerConn.signalingState != 'closed') this.peerConn.close(); if (this.peerConn && this.peerConn.signalingState != 'closed') this.peerConn.close();
if (this.onHangup) this.onHangup(this); if (this.onHangup) this.onHangup(this);

View File

@ -145,7 +145,7 @@ angular.module('matrixPhoneService', [])
call.initWithHangup(event); call.initWithHangup(event);
matrixPhoneService.allCalls[msg.call_id] = call; matrixPhoneService.allCalls[msg.call_id] = call;
} else { } else {
call.onHangupReceived(); call.onHangupReceived(msg);
delete(matrixPhoneService.allCalls[msg.call_id]); delete(matrixPhoneService.allCalls[msg.call_id]);
} }
} }