summary refs log tree commit diff
path: root/webclient/room
diff options
context:
space:
mode:
authorDavid Baker <dbkr@matrix.org>2014-08-29 11:33:36 +0100
committerDavid Baker <dbkr@matrix.org>2014-08-29 11:33:36 +0100
commit171d8b032f9494fcfe720ec66ebb807bfb3b1de5 (patch)
tree4826e8cf9fef892e78f9418e8c0bae0149a8b9fd /webclient/room
parentCleaned up ng deps. By convention, angular modules must be listed at first (diff)
parentMore basic functionality for voip calls (like hanging up) (diff)
downloadsynapse-171d8b032f9494fcfe720ec66ebb807bfb3b1de5.tar.xz
Merge branch 'voip' into develop
Conflicts:
	webclient/room/room-controller.js
Diffstat (limited to 'webclient/room')
-rw-r--r--webclient/room/room-controller.js37
-rw-r--r--webclient/room/room.html8
2 files changed, 43 insertions, 2 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 71b6720604..15710d2ba3 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -15,8 +15,8 @@ limitations under the License.
 */
 
 angular.module('RoomController', ['ngSanitize', 'mFileInput'])
-.controller('RoomController', ['$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload',
-                               function($scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload) {
+.controller('RoomController', ['$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall',
+                               function($scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall) {
    'use strict';
     var MESSAGES_PER_PAGINATION = 30;
     var THUMBNAIL_SIZE = 320;
@@ -82,6 +82,13 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
     $scope.$on(eventHandlerService.PRESENCE_EVENT, function(ngEvent, event, isLive) {
         updatePresence(event);
     });
+
+    $rootScope.$on(matrixPhoneService.CALL_EVENT, function(ngEvent, call) {
+        console.trace("incoming call");
+        call.onError = $scope.onCallError;
+        call.onHangup = $scope.onCallHangup;
+        $scope.currentCall = call;
+    });
     
     $scope.paginateMore = function() {
         if ($scope.state.can_paginate) {
@@ -89,6 +96,15 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
             paginate(MESSAGES_PER_PAGINATION);
         }
     };
+
+    $scope.answerCall = function() {
+        $scope.currentCall.answer();
+    };
+
+    $scope.hangupCall = function() {
+        $scope.currentCall.hangup();
+        $scope.currentCall = undefined;
+    };
         
     var paginate = function(numItems) {
         // console.log("paginate " + numItems);
@@ -454,4 +470,21 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
     $scope.loadMoreHistory = function() {
         paginate(MESSAGES_PER_PAGINATION);
     };
+
+    $scope.startVoiceCall = function() {
+        var call = new MatrixCall($scope.room_id);
+        call.onError = $scope.onCallError;
+        call.onHangup = $scope.onCallHangup;
+        call.placeCall();
+        $scope.currentCall = call;
+    }
+
+    $scope.onCallError = function(errStr) {
+        $scope.feedback = errStr;
+    }
+
+    $scope.onCallHangup = function() {
+        $scope.feedback = "Call ended";
+        $scope.currentCall = undefined;
+    }
 }]);
diff --git a/webclient/room/room.html b/webclient/room/room.html
index 7443b2f77b..572c52e64e 100644
--- a/webclient/room/room.html
+++ b/webclient/room/room.html
@@ -98,6 +98,14 @@
                         <button ng-click="inviteUser(userIDToInvite)">Invite</button>
                 </span>
                 <button ng-click="leaveRoom()">Leave</button>
+                <button ng-click="startVoiceCall()" ng-show="currentCall == undefined">Voice Call</button>
+                <div ng-show="currentCall.state == 'ringing'">
+                Incoming call from {{ currentCall.user_id }}
+                <button ng-click="answerCall()">Answer</button>
+                <button ng-click="hangupCall()">Reject</button>
+                </div>
+                <button ng-click="hangupCall()" ng-show="currentCall && currentCall.state != 'ringing'">Hang up</button>
+                {{ currentCall.state }}
             </div>
         
             {{ feedback }}