Console can be a client or server ipc

This commit is contained in:
Anthony Laibe 2018-08-30 15:45:01 +01:00
parent bd49e3672c
commit 59e82d5fc6
2 changed files with 18 additions and 5 deletions

View File

@ -80,7 +80,8 @@ class EmbarkController {
context: self.context, context: self.context,
useDashboard: options.useDashboard, useDashboard: options.useDashboard,
webServerConfig: webServerConfig, webServerConfig: webServerConfig,
webpackConfigName: options.webpackConfigName webpackConfigName: options.webpackConfigName,
ipcRole: 'server'
}); });
engine.init(); engine.init();
@ -256,7 +257,6 @@ class EmbarkController {
logFile: options.logFile, logFile: options.logFile,
logLevel: options.logLevel, logLevel: options.logLevel,
context: this.context, context: this.context,
ipcRole: 'client',
webpackConfigName: options.webpackConfigName webpackConfigName: options.webpackConfigName
}); });
engine.init(); engine.init();

View File

@ -38,10 +38,23 @@ class Engine {
utils.interceptLogs(console, this.logger); utils.interceptLogs(console, this.logger);
} }
if (this.ipcRole) {
this.ipc = new IPC({logger: this.logger, ipcRole: this.ipcRole}); this.ipc = new IPC({logger: this.logger, ipcRole: this.ipcRole});
if(this.ipc.isServer()) { if(this.ipc.isServer()) {
this.ipc.serve(); this.ipc.serve();
} }
return;
}
this.ipc = new IPC({logger: this.logger, ipcRole: 'client'});
this.ipc.connect((err) => {
if(err) {
this.ipc = new IPC({logger: this.logger, ipcRole: 'server'});
this.ipc.serve();
}
});
} }
registerModule(moduleName, options) { registerModule(moduleName, options) {