Browse Source

Fixed timeouts in case of disconnects.

pull/18/head
Simon Eisenmann 11 years ago
parent
commit
0059cefa68
  1. 11
      static/js/controllers/mediastreamcontroller.js

11
static/js/controllers/mediastreamcontroller.js

@ -291,8 +291,8 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
if (id) { if (id) {
console.log("Auto accept requested", id); console.log("Auto accept requested", id);
$scope.autoAccept = id; $scope.autoAccept = id;
$window.clearTimeout(autoAcceptTimeout); $timeout.cancel(autoAcceptTimeout);
autoAcceptTimeout = window.setTimeout(function() { autoAcceptTimeout = $timeout(function() {
$scope.autoAccept=null; $scope.autoAccept=null;
console.warn("Auto accept expired!") console.warn("Auto accept expired!")
safeApply($scope); safeApply($scope);
@ -300,7 +300,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
} else { } else {
if ($scope.autoAccept && $scope.autoAccept === from) { if ($scope.autoAccept && $scope.autoAccept === from) {
$scope.autoAccept = null; $scope.autoAccept = null;
$window.clearTimeout(autoAcceptTimeout); $timeout.cancel(autoAcceptTimeout);
console.log("Auto accept success", from) console.log("Auto accept success", from)
return from; return from;
} }
@ -365,7 +365,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
var reloadDialog = false; var reloadDialog = false;
mediaStream.api.e.on("received.self", function(event, data) { mediaStream.api.e.on("received.self", function(event, data) {
$window.clearTimeout(ttlTimeout); $timeout.cancel(ttlTimeout);
safeApply($scope, function(scope) { safeApply($scope, function(scope) {
scope.id = scope.myid = data.Id; scope.id = scope.myid = data.Id;
scope.turn = data.Turn; scope.turn = data.Turn;
@ -387,7 +387,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
} }
// Support to upgrade stuff when ttl was reached. // Support to upgrade stuff when ttl was reached.
if (data.Turn.ttl) { if (data.Turn.ttl) {
ttlTimeout = $window.setTimeout(function() { ttlTimeout = $timeout(function() {
console.log("Ttl reached - sending refresh request."); console.log("Ttl reached - sending refresh request.");
mediaStream.api.sendSelf(); mediaStream.api.sendSelf();
}, data.Turn.ttl / 100 * 90 * 1000); }, data.Turn.ttl / 100 * 90 * 1000);
@ -508,6 +508,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS
mediaStream.connector.e.on("open error close", function(event, options) { mediaStream.connector.e.on("open error close", function(event, options) {
var t = event.type; var t = event.type;
var opts = $.extend({}, options); var opts = $.extend({}, options);
$timeout.cancel(ttlTimeout);
switch (t) { switch (t) {
case "open": case "open":
t = "waiting"; t = "waiting";

Loading…
Cancel
Save