From 6db1a1300c43a7713f07747565168b305db6ff83 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Mon, 29 Aug 2016 12:48:13 +0200 Subject: [PATCH 1/2] Add label support for TURN service --- dependencies.tsv | 2 +- static/js/app.js | 1 + static/js/services/turndata.js | 40 +++++++++++++++++++++++++++++----- static/partials/settings.html | 7 +++--- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/dependencies.tsv b/dependencies.tsv index 50801999..651d744d 100644 --- a/dependencies.tsv +++ b/dependencies.tsv @@ -10,4 +10,4 @@ github.com/strukturag/goacceptlanguageparser git 68066e68c2940059aadc6e19661610c github.com/strukturag/httputils git afbf05c71ac03ee7989c96d033a9571ba4ded468 2014-07-02T01:35:33Z github.com/strukturag/phoenix git 31b7f25f4815e6e0b8e7c4010f6e9a71c4165b19 2016-06-01T11:34:58Z github.com/strukturag/sloth git 74a8bcf67368de59baafe5d3e17aee9875564cfc 2015-04-22T08:59:42Z -github.com/strukturag/spreed-turnservicecli git 51f45889f0c6a4a7d406c29b9cc345b07a1a94ab 2016-08-26T13:54:01Z +github.com/strukturag/spreed-turnservicecli git dcbf3f8eab1c36d4d0e4c6f9b6dce4f060543224 2016-08-29T09:55:47Z diff --git a/static/js/app.js b/static/js/app.js index c6cc7736..fa295ac7 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -267,6 +267,7 @@ define([ }()); console.info("Selected language: "+lang); + app.constant("translationLanguage", {lang: lang}); // Set language and load default translations. launcher.translationData.lang = lang; diff --git a/static/js/services/turndata.js b/static/js/services/turndata.js index 22f11a54..060f1308 100644 --- a/static/js/services/turndata.js +++ b/static/js/services/turndata.js @@ -26,7 +26,7 @@ define(["jquery"], function($) { var refreshPercentile = 90; // Percent of the TTL when TURN credentials should be refreshed. // turnData - return ["$timeout", "$http", "api", "randomGen", "appData", function($timeout, $http, api, randomGen, appData) { + return ["$timeout", "$http", "api", "randomGen", "appData", "translationLanguage", function($timeout, $http, api, randomGen, appData, translationLanguage) { var ttlTimeout = null; var geoRefresh = null; var geoPreferred = null; @@ -44,24 +44,52 @@ define(["jquery"], function($) { }; if (turn && turn.servers) { // Multiple options, need to sort and use settings. + var i; if (!turn.serverMap) { var servers = {}; + var serversSelectable = []; + // Sort for prio. turn.servers.sort(function(a, b) { servers[a.id] = a; servers[b.id] = b; return (a.prio > b.prio) ? 1 : ((a.prio < b.prio) ? -1 : 0); }); turn.first = turn.servers[0]; - if (turn.geo_uri) { - turn.servers.unshift({ - "id": "auto" + // Create selectable servers. + var lang = translationLanguage.lang; + for (i=0; i 0) { + serversSelectable.unshift({ + "id": "auto", + "label": "auto" }) } + // Make created data available. turn.serverMap = servers; + turn.serversSelectable = serversSelectable; } var urls; if (turn.preferred) { - for (var i=0; i -
- +
+
- - {{_('Geographic region for TURN service.')}} +
From 873ec19462b2b0c84b04c803c422bbfdfadf6ae2 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Mon, 29 Aug 2016 12:56:40 +0200 Subject: [PATCH 2/2] Add minimal TURN refresh interval --- static/js/services/turndata.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/js/services/turndata.js b/static/js/services/turndata.js index 060f1308..c88378e8 100644 --- a/static/js/services/turndata.js +++ b/static/js/services/turndata.js @@ -24,6 +24,7 @@ define(["jquery"], function($) { var geoRequestTimeout = 30000; // Timeout for geo requests in milliseconds. var geoFastRetryTimeout = 45000; // Refresh timer in milliseconds, after which GEO requests should be retried if failed before. var refreshPercentile = 90; // Percent of the TTL when TURN credentials should be refreshed. + var refreshMinimumInterval = 30000; // Minimal TURN refresh interval in milliseconds. // turnData return ["$timeout", "$http", "api", "randomGen", "appData", "translationLanguage", function($timeout, $http, api, randomGen, appData, translationLanguage) { @@ -190,10 +191,14 @@ define(["jquery"], function($) { // Support to refresh TURN data when ttl was reached. if (turn.ttl) { + var timer = turn.ttl * 0.01 * refreshPercentile * 1000; + if (timer < refreshMinimumInterval) { + timer = refreshMinimumInterval; + } ttlTimeout = $timeout(function() { console.log("TURN TTL reached - sending refresh request."); api.sendSelf(); - }, turn.ttl * 0.01 * refreshPercentile * 1000); + }, timer); } };