summary refs log tree commit diff
path: root/webclient
diff options
context:
space:
mode:
authorDavid Baker <dbkr@matrix.org>2014-09-22 11:44:15 +0100
committerDavid Baker <dbkr@matrix.org>2014-09-22 11:44:15 +0100
commit4696622b0a10fff517f88a5f47b0806705196d39 (patch)
tree0c3cfd536f84c9be580129353cf98bd69f42afc4 /webclient
parentBetter logging of ICE candidates and fail the call when ICE fails. (diff)
downloadsynapse-4696622b0a10fff517f88a5f47b0806705196d39.tar.xz
Propagate failure reason to the other party.
Diffstat (limited to 'webclient')
-rw-r--r--webclient/components/matrix/matrix-call.js13
-rw-r--r--webclient/components/matrix/matrix-phone-service.js2
2 files changed, 8 insertions, 7 deletions
diff --git a/webclient/components/matrix/matrix-call.js b/webclient/components/matrix/matrix-call.js
index d8571e7036..9d3a787291 100644
--- a/webclient/components/matrix/matrix-call.js
+++ b/webclient/components/matrix/matrix-call.js
@@ -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);
 
         // 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();
 
         this.hangupParty = 'local';
+        this.hangupReason = reason;
 
         var content = {
             version: 0,
             call_id: this.call_id,
+            reason: reason
         };
         this.sendEventWithRetry('m.call.hangup', content);
         this.state = 'ended';
@@ -324,8 +326,7 @@ angular.module('MatrixCall', [])
         var self = this;
         $timeout(function() {
             if (self.state == 'invite_sent') {
-                self.hangupReason = 'invite_timeout';
-                self.hangup();
+                self.hangup('invite_timeout');
             }
         }, MatrixCall.CALL_TIMEOUT);
 
@@ -369,8 +370,7 @@ angular.module('MatrixCall', [])
                 self.didConnect = true;
             });
         } else if (this.peerConn.iceConnectionState == 'failed') {
-            this.hangupReason = 'ice_failed';
-            this.hangup();
+            this.hangup('ice_failed');
         }
     };
 
@@ -448,12 +448,13 @@ angular.module('MatrixCall', [])
         });
     };
 
-    MatrixCall.prototype.onHangupReceived = function() {
+    MatrixCall.prototype.onHangupReceived = function(msg) {
         console.log("Hangup received");
         if (this.remoteVideoElement) this.remoteVideoElement.pause();
         if (this.localVideoElement) this.localVideoElement.pause();
         this.state = 'ended';
         this.hangupParty = 'remote';
+        this.hangupReason = msg.reason;
         this.stopAllMedia();
         if (this.peerConn && this.peerConn.signalingState != 'closed') this.peerConn.close();
         if (this.onHangup) this.onHangup(this);
diff --git a/webclient/components/matrix/matrix-phone-service.js b/webclient/components/matrix/matrix-phone-service.js
index 9d0b84fb23..06465ed821 100644
--- a/webclient/components/matrix/matrix-phone-service.js
+++ b/webclient/components/matrix/matrix-phone-service.js
@@ -145,7 +145,7 @@ angular.module('matrixPhoneService', [])
                 call.initWithHangup(event);
                 matrixPhoneService.allCalls[msg.call_id] = call;
             } else {
-                call.onHangupReceived();
+                call.onHangupReceived(msg);
                 delete(matrixPhoneService.allCalls[msg.call_id]);
             }
         }