Created
March 4, 2019 01:58
-
-
Save bushev/1c9586d20512aab3da469454de084a53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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