[Sciviews-commits] r243 - komodo/SciViews-K/content/js
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 23 23:21:10 CET 2010
Author: prezez
Date: 2010-01-23 23:21:10 +0100 (Sat, 23 Jan 2010)
New Revision: 243
Modified:
komodo/SciViews-K/content/js/socket.js
Log:
Fixed: communication with R breaking when Komodo goes offline (sv.socket.rClient restores online state now).
Modified: komodo/SciViews-K/content/js/socket.js
===================================================================
--- komodo/SciViews-K/content/js/socket.js 2010-01-23 13:43:40 UTC (rev 242)
+++ komodo/SciViews-K/content/js/socket.js 2010-01-23 22:21:10 UTC (rev 243)
@@ -42,7 +42,8 @@
/////// Socket client //////////////////////////////////////////////////////
this.svSocketMinVersion = "0.9-48"; // Will be used later for compatibility
// checking between R and Komodo tools
- this.host = "127.0.0.1"; // Host to connect to (local host only, currently)
+ //this.host = "127.0.0.1"; // Host to connect to (local host only, currently)
+ //host address is now controlled by the preference value "sciviews.server.host"
this.cmdout = true; // Do we write to 'Command Output'?
this.prompt = ":> "; // The prompt, could be changed to continue prompt
this.cmd = ""; // The command to send to R
@@ -57,6 +58,18 @@
// The main socket client function to connect to R socket server
this.rClient = function (host, port, outputData, listener, echo, echofun) {
+ // workaround for NS_ERROR_OFFLINE returned by 'createTransport' when
+ // there is no network connection (happens only when network goes down while Komodo
+ // is running)
+ // this code is based on 'toggleOfflineStatus' function in:
+ // chrome://browser/content/browser.js
+ if (!navigator.onLine) {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"].
+ getService(Components.interfaces.nsIIOService2);
+ ioService.offline = false;
+ //ioService.manageOfflineStatus = false;
+ }
+
try {
var transportService = Components.
classes["@mozilla.org/network/socket-transport-service;1"]
@@ -175,18 +188,21 @@
}
// TODO: deal with error checking for this command
var port = sv.prefs.getString("sciviews.client.socket", "8888");
+ var host = sv.prefs.getString("sciviews.server.host", "127.0.0.1");
+
var id = "<<<id=" +
sv.prefs.getString("sciviews.client.id", "SciViewsK") + ">>>";
- var res = _this.rClient(_this.host, port, id + cmd + "\n",
+ var res = _this.rClient(host, port, id + cmd + "\n",
listener, echo, echofun);
// BUG: (windows/linux?) if network connection is turned off while komodo is
// running, navigator.onLine is set to false, and we get an
// NS_ERROR_OFFLINE here, even if the socket connection with R is on:
+ // KB: This should be fixed now.
// if exception was returned:
if (res && res.name && res.name == "NS_ERROR_OFFLINE") {
- sv.cmdout.message("Error: R is unreachable (see log)", 5000, true);
+ sv.cmdout.message("Error: Komodo went offline!", 5000, true);
}
return(res);
}
More information about the Sciviews-commits
mailing list