this.addonManager = null;
this.isLaunched = false;
this.inspectorEnabledByVconf = false;
+ this.sandbox = [];
this.webContents = null;
var _this = this;
});
wrt.on('message', function(event, type, params) {
console.log('message type(' + type + ') params : ' + params);
+ const app_id = params[0];
+ const vm = require('vm');
if (type === 'startService') {
- const vm = require('vm');
- const fs = require('fs');
- let sandbox = {
- console: console,
- module: module,
- require: require,
- };
- let options = {};
- let code = fs.readFileSync(params[1]);
- vm.runInNewContext(code, sandbox, options);
+ if (_this.sandbox[app_id] === undefined) {
+ const fs = require('fs');
+ _this.sandbox[app_id] = {
+ console: console,
+ module: module,
+ require: require,
+ };
+ let options = {};
+ let code = fs.readFileSync(params[1]);
+ vm.runInNewContext(code, _this.sandbox[app_id], options);
+ }
+ if (_this.sandbox[app_id]['started'] === undefined) {
+ _this.sandbox[app_id]['started'] = true;
+ _this.sandbox[app_id]['stopped'] = undefined;
+ const start_callback_string = 'if (module.exports.onStart !== undefined) { module.exports.onStart(); }';
+ vm.runInContext(start_callback_string, _this.sandbox[app_id]);
+ } else {
+ console.log('UI service has been started.');
+ }
+ event.preventDefault();
+ } else if (type === 'stopService') {
+ if (_this.sandbox[app_id]['stopped'] === undefined) {
+ _this.sandbox[app_id]['stopped'] = true;
+ _this.sandbox[app_id]['started'] = undefined;
+ const stop_callback_string = 'if (module.exports.onStop !== undefined) { module.exports.onStop(); }';
+ vm.runInContext(stop_callback_string, _this.sandbox[app_id]);
+ _this.sandbox[app_id] = undefined;
+ } else {
+ console.log('UI service has been stopped.');
+ }
event.preventDefault();
}
});