Skip to content

Commit

Permalink
#417 / #1581: set bandwidth-limit to the value we get from the browse…
Browse files Browse the repository at this point in the history
…r's "downlink" network information

git-svn-id: https://xpra.org/svn/Xpra/trunk@17255 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 26, 2017
1 parent 0d912ca commit f361a75
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ <h4 class="panel-title">Advanced options</h4>
<div id="hiddenopts" class="panel-collapse collapse in" role="tabpanel" style="display:none;">
<ul class="list-group">

<li class="list-group-item">
<select id="bandwidth_limit">
<option value="0">None</option>
<option value="100000000">100Mbps</option>
<option value="10000000">10Mbps</option>
<option value="1000000">1Mbps</option>
</select>
Bandwith Constraint
</li>

<li class="list-group-item">
<select id="encoding">
<option value="auto">Automatic</option>
Expand Down Expand Up @@ -311,7 +321,7 @@ <h4 class="panel-title">Advanced options</h4>
}
}
add_prop("submit", true);
var val_props = ["server", "port", "username", "password", "encoding", "keyboard_layout", "audio_codec"];
var val_props = ["server", "port", "username", "password", "bandwidth_limit", "encoding", "keyboard_layout", "audio_codec"];
for (var i = 0; i < val_props.length; i++) {
var prop = val_props[i];
var value = document.getElementById(prop).value;
Expand Down Expand Up @@ -417,6 +427,15 @@ <h4 class="panel-title">Advanced options</h4>
var encoding = getparam("encoding") || "auto";
document.getElementById('encoding').value = encoding;

var bandwidth_limit = getparam("bandwidth_limit");
if(bandwidth_limit==null) {
var ci = Utilities.getConnectionInfo();
if (ci) {
bandwidth_limit = ci["downlink"];
}
}
document.getElementById('bandwidth_limit').value = bandwidth_limit || 0;

var keyboard_layout = Utilities.getKeyboardLayout();
document.getElementById('keyboard_layout').value = keyboard_layout;
try {
Expand Down
3 changes: 3 additions & 0 deletions src/html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
var sound = getboolparam("sound") || null;
var audio_codec = getparam("audio_codec") || null;
var encoding = getparam("encoding") || null;
var bandwidth_limit = getparam("bandwidth_limit") || 0;
var action = getparam("action") || "connect";
var submit = getboolparam("submit", true);
var server = getparam("server") || window.location.hostname;
Expand Down Expand Up @@ -199,6 +200,7 @@
client.clipboard_enabled = clipboard;
client.printing = printing;
client.file_transfer = file_transfer;
client.bandwidth_limit = bandwidth_limit;
client.steal = steal;
client.reconnect = reconnect;
client.swap_keys = swap_keys;
Expand Down Expand Up @@ -319,6 +321,7 @@
"server" : server,
"port" : port,
"encoding" : encoding,
"bandwidth_limit" : bandwidth_limit,
"keyboard_layout" : keyboard_layout,
"action" : action,
"sound" : sound,
Expand Down
6 changes: 6 additions & 0 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ XpraClient.prototype.init_settings = function(container) {
this.file_transfer = false;
this.keyboard_layout = null;
this.printing = false;
this.bandwidth_limit = 0;
this.reconnect = true;
this.reconnect_count = 5;
this.reconnect_in_progress = false;
Expand Down Expand Up @@ -970,6 +971,11 @@ XpraClient.prototype._make_hello_base = function() {
"bencode" : true,
"yaml" : false,
});
if (this.bandwidth_limit>0) {
this._update_capabilities({
"bandwidth-limit" : this.bandwidth_limit,
})
}
var ci = Utilities.getConnectionInfo();
if (ci) {
this._update_capabilities({
Expand Down

0 comments on commit f361a75

Please sign in to comment.