improved aria2 connection handling

This commit is contained in:
Hamza Zia 2012-10-02 11:06:37 -07:00
parent 2bc0f3a90a
commit b20ad0d04e
3 changed files with 11 additions and 5 deletions

View File

@ -565,7 +565,7 @@
<div class="control-group">
<label class="control-label" for="input_host">Enter the host:</label>
<div class="controls">
<div class="input-prepend"><span class="add-on">http://</span><input type="text" class="input-xlarge" id="input_host" placeholder="localhost"/></div>
<div class="input-prepend"><span class="add-on">http(s)://</span><input type="text" class="input-xlarge" id="input_host" placeholder="localhost"/></div>
<p class="help-block">Enter the ip or dns name of the server on which the rpc for aria2 is running (default = localhost)</p>
</div>
<label class="control-label" for="input_port">Enter the port:</label>

View File

@ -87,7 +87,7 @@ var SocketRPC = function(conf) {
rpc.initialized = true;
};
rpc.sock.onclose = rpc.sock.onerror = function() {
_.each(handles, function(h) { h.error() });
_.each(rpc.handles, function(h) { h.error() });
rpc.handles = [];
};
rpc.sock.onmessage = function(message) {

View File

@ -25,16 +25,18 @@ var server_conf = {
port: 6800,
user: "",
pass: "",
encryption: false
encryption: false,
dirty: false
};
var ariaConnection = new AriaConnection(server_conf);
var ariaConnection;
var set_conf_cookie = function() {
setCookie('aria2_server_conf', JSON.stringify(server_conf), 30 * 12);
}
var get_conf_cookie = function() {
if (getCookie( $.trim('aria2_server_conf'))) {
server_conf = JSON.parse(getCookie('aria2_server_conf'));
server_conf.dirty = false;
}
}
var custom_aria2_connect = function() {
@ -58,6 +60,7 @@ var update_server_conf = function() {
if(port.length !== 0) {
server_conf.port = port;
}
server_conf.dirty = false;
set_conf_cookie();
ariaConnection = new AriaConnection(server_conf);
clear_dialogs();
@ -69,6 +72,7 @@ var aria_syscall = function(conf, multicall, old) {
ariaConnection.invoke(conf);
}
var update_ui = function() {
if (!server_conf.dirty)
updateDownloads();
};
@ -93,6 +97,7 @@ $(function() {
modals.new_torrent_modal = $('#new_torrent').modal(modal_conf);
modals.new_metalink_modal = $('#new_metalink').modal(modal_conf);
ariaConnection = new AriaConnection(server_conf)
update_ui();
globalGraphData = {
downSpeed: [],
@ -931,6 +936,7 @@ function updateDownloads() {
updateGlobalStatistics(data.result[3][0]);
},
error: function() {
server_conf.dirty = true;
modals.err_connect.modal('show');
}
}, true);