kopia lustrzana https://github.com/c9/core
Merge pull request +14092 from c9/ide-tune-vfs-ping
Only measure latency when websocket seems idlepull/313/head
commit
3b47a914a5
|
@ -68,7 +68,7 @@
|
||||||
"c9.ide.language.javascript.eslint": "#4de5457db1",
|
"c9.ide.language.javascript.eslint": "#4de5457db1",
|
||||||
"c9.ide.language.javascript.tern": "#64ab01f271",
|
"c9.ide.language.javascript.tern": "#64ab01f271",
|
||||||
"c9.ide.language.javascript.infer": "#69fbc134d6",
|
"c9.ide.language.javascript.infer": "#69fbc134d6",
|
||||||
"c9.ide.language.jsonalyzer": "#d8183d84b4",
|
"c9.ide.language.jsonalyzer": "#ce973ed167",
|
||||||
"c9.ide.language.codeintel": "#fc867feec4",
|
"c9.ide.language.codeintel": "#fc867feec4",
|
||||||
"c9.ide.collab": "#cfbf987438",
|
"c9.ide.collab": "#cfbf987438",
|
||||||
"c9.ide.local": "#10eb45842a",
|
"c9.ide.local": "#10eb45842a",
|
||||||
|
|
|
@ -9,6 +9,7 @@ define(function(require, exports, module) {
|
||||||
var Plugin = imports.Plugin;
|
var Plugin = imports.Plugin;
|
||||||
var c9 = imports.c9;
|
var c9 = imports.c9;
|
||||||
var ext = imports.ext;
|
var ext = imports.ext;
|
||||||
|
var vfs = imports.vfs;
|
||||||
|
|
||||||
/***** Initialization *****/
|
/***** Initialization *****/
|
||||||
|
|
||||||
|
@ -61,6 +62,9 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!api) return callback(new Error("Client is offline"));
|
if (!api) return callback(new Error("Client is offline"));
|
||||||
|
|
||||||
|
if (!vfs.isIdle())
|
||||||
|
return vfs.connection.once("message", ping.bind(null, callback));
|
||||||
|
|
||||||
var start = Date.now();
|
var start = Date.now();
|
||||||
api.ping("serverTime", function(err, response) {
|
api.ping("serverTime", function(err, response) {
|
||||||
|
|
|
@ -329,6 +329,11 @@ define(function(require, exports, module) {
|
||||||
bufferedVfsCalls.push([method, path, options, callback]);
|
bufferedVfsCalls.push([method, path, options, callback]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isIdle() {
|
||||||
|
return !Object.keys(connection.unacked).length &&
|
||||||
|
consumer && !Object.keys(consumer.callbacks || {}).length;
|
||||||
|
}
|
||||||
|
|
||||||
/***** Lifecycle *****/
|
/***** Lifecycle *****/
|
||||||
|
|
||||||
plugin.on("load", function(){
|
plugin.on("load", function(){
|
||||||
|
@ -429,7 +434,9 @@ define(function(require, exports, module) {
|
||||||
// Extending the API
|
// Extending the API
|
||||||
use: vfsCall.bind(null, "use"),
|
use: vfsCall.bind(null, "use"),
|
||||||
extend: vfsCall.bind(null, "extend"),
|
extend: vfsCall.bind(null, "extend"),
|
||||||
unextend: vfsCall.bind(null, "unextend")
|
unextend: vfsCall.bind(null, "unextend"),
|
||||||
|
|
||||||
|
isIdle: isIdle,
|
||||||
});
|
});
|
||||||
|
|
||||||
register(null, {
|
register(null, {
|
||||||
|
|
Ładowanie…
Reference in New Issue