Skip to content

Instantly share code, notes, and snippets.

@bushev
Created March 4, 2019 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bushev/1c9586d20512aab3da469454de084a53 to your computer and use it in GitHub Desktop.
Save bushev/1c9586d20512aab3da469454de084a53 to your computer and use it in GitHub Desktop.
const {Service} = require('moleculer');
const {app, ipcMain} = require('electron');
class ElectronService extends Service {
constructor(broker) {
super(broker);
this.parseServiceSchema({
name: 'electron',
created: this.serviceCreated
});
}
serviceCreated() {
this.logger.info(`Electron Service created. PID ${process.pid}`);
ipcMain.on('call', async (event, notification) => {
this.logger.info(`Call service: ${notification.service}`);
event.sender.send('call-result', {
id: notification.callId,
result: await this.broker.call(notification.service, notification.params)
});
});
}
}
module.exports = ElectronService;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment