kopia lustrzana https://github.com/c9/core
propagate workspace state changes to the client and trigger a VFS reconnect
rodzic
93c35f41d2
commit
90a8611f78
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* Listens to pub sub events from the VFS server and reconnects VFS as neccessary
|
||||
*/
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
main.consumes = [
|
||||
"Plugin", "pubsub", "vfs", "metrics"
|
||||
];
|
||||
main.provides = ["vfs.listener"];
|
||||
return main;
|
||||
|
||||
function main(options, imports, register) {
|
||||
var Plugin = imports.Plugin;
|
||||
var pubsub = imports.pubsub;
|
||||
var vfs = imports.vfs;
|
||||
var metrics = imports.metrics;
|
||||
|
||||
/***** Initialization *****/
|
||||
|
||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
||||
|
||||
var loaded = false;
|
||||
function load() {
|
||||
if (loaded) return false;
|
||||
loaded = true;
|
||||
|
||||
pubsub.on("message", function(m) {
|
||||
if (m.type !== "workspace") return;
|
||||
|
||||
if (m.action == "state_changed") {
|
||||
metrics.increment("vfs.state_changed", 1, true);
|
||||
vfs.reconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/***** Lifecycle *****/
|
||||
|
||||
plugin.on("load", function() {
|
||||
load();
|
||||
});
|
||||
plugin.on("unload", function() {
|
||||
loaded = false;
|
||||
});
|
||||
|
||||
/***** Register and define API *****/
|
||||
|
||||
plugin.freezePublicAPI({});
|
||||
|
||||
register(null, {
|
||||
"vfs.listener": plugin
|
||||
});
|
||||
}
|
||||
});
|
|
@ -55,7 +55,6 @@ define(function(require, exports, module) {
|
|||
errorDialog.vfs = plugin;
|
||||
|
||||
var buffer = [];
|
||||
var withInstall = options.withInstall;
|
||||
var dashboardUrl = options.dashboardUrl;
|
||||
var region, vfsBaseUrl, homeUrl, projectUrl, pingUrl, serviceUrl;
|
||||
var eioOptions, connection, consumer, vfs;
|
||||
|
@ -384,6 +383,11 @@ define(function(require, exports, module) {
|
|||
rest: rest,
|
||||
download: download,
|
||||
url: vfsUrl,
|
||||
reconnect: function() {
|
||||
reconnect(function(_err) {
|
||||
connection.connect();
|
||||
});
|
||||
},
|
||||
|
||||
// File management
|
||||
resolve: vfsCall.bind(null, "resolve"),
|
||||
|
|
Ładowanie…
Reference in New Issue