Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
kickstart() {
// Config IPC
ipc.config.id = 'switch-service-channel';
ipc.config.retry = 1500;
ipc.config.silent = true;
// Serve, then listen to incoming events
ipc.serve(() => ipc.server.on('switch-service-incoming', (message, _socket) => {
socket = _socket;
const msg: ProcessMessage = JSON.parse(message);
switch (msg.type) {
case 'update-hot-apps':
this.emitter.emit('update-hot-apps', msg.data)
break;
case 'client-pid':
this.emitter.emit('client-pid', msg.data);
break;
case 'config-update':
this.emitter.emit('config-update', msg.data);
// send config update to client..
this.sendConfigUpdateToDockClient(msg.data);
break;
case 'show-dock':
console.log('[info] Show dock');
constructor(config: Config, methodsMap: MethodsMap) {
// setup config
ipc.config.id = config.serverName;
ipc.config.silent = !config.debug;
ipc.config.logInColor = true;
// create socket
ipc.serve(() => {
ipc.log('server started');
});
ipc.server.on('ping', (input, socket) => {
ipc.server.emit(socket, 'ping', { response: true });
});
ipc.server.on('stop', () => {
ipc.server.stop();
});
// register rpc methods
// TODO: somehow listen for events which are not registered
_forEach(methodsMap, (methodFunc, methodName) => {
ipc.log('register', methodName);
ipc.server.on(methodName, (input, socket) => {
import store from 'browser/main/store'
import ConfigManager from 'browser/main/lib/ConfigManager'
const nodeIpc = require('node-ipc')
const { remote, ipcRenderer } = require('electron')
const { app, Menu } = remote
const path = require('path')
nodeIpc.config.id = 'node'
nodeIpc.config.retry = 1500
nodeIpc.config.silent = true
console.log('Initializing IPC Server')
// TODO: IPC SERVER WILL BE MOVED TO MAIN PROCESS FROM MAIN WINDOW PROCESS(RENDERER)
nodeIpc.serve(
path.join(app.getPath('userData'), 'boostnote.service'),
function () {
console.log('IPC Server Started')
ipcRenderer.on('open-finder', function () {
console.log('Open finder')
nodeIpc.server.broadcast('open-finder')
})
/** Quit Sequence
1. `quit-app` Main process -> Main window by Electron IPC
2. `quit-finder-app` Main window -> Finder window by Node IPC(socket)
3. Finder window (and Finder main process: OSX only) killed by remote API
4. `quit-finder-app-confirm` Finder window -> Main window by NodeIPC
5. `quit-app-confirm` Main window -> Main process by Electron IPC
6. Main process discard close preventer and terminate Main window and itself.
ipc.serve(() => ipc.server.on('switch-service-incoming', (message, _socket) => {
socket = _socket;
const msg = JSON.parse(message);
switch (msg.type) {
case 'update-hot-apps':
this.emitter.emit('update-hot-apps', msg.data);
break;
case 'client-pid':
this.emitter.emit('client-pid', msg.data);
break;
case 'config-update':
this.emitter.emit('config-update', msg.data);
this.sendConfigUpdateToDockClient(msg.data);
break;
case 'show-dock':
console.log('[info] Show dock');
this.sendShowClient();
start(ipcCommunicatorCallback: IpcCommunicatorCallback): void {
console.log("starting ipc-uds");
ipc.serve(() => this.onConnect());
ipc.server.start();
}
start_ipc(){
ipc.serve(()=>{
ipc.server.on('upgrader_connected', (data, socket)=>{
this.upgrader_socket = socket;
this.ipc_cb();
delete this.ipc_cb;
});
ipc.server.on('upgrade_finished', ({error, cli})=>{
if (cli)
this.upgrade_downgrade_cli(error);
else if (this.child)
this.child.send({command: 'upgrade_finished', error});
});
ipc.server.on('downgrade_finished', ({error, cli})=>{
if (cli)
this.upgrade_downgrade_cli(error, 1);
else if (this.child)
this.child.send({command: 'downgrade_finished', error});
constructor(public readonly host: string) {
this.sdk = new BundleStoreSdk(host)
this.assets = []
ipc.config.silent = true
ipc.config.id = 'ern-bundle-store'
ipc.serve(() => {
ipc.server.on('assets', (data, socket) => {
log.debug(`received asset : ${JSON.stringify(data)}`)
this.assets.push(JSON.parse(data))
})
})
ipc.server.start()
}
globalShortcut.register(config.hotkey.toggleMain, toggleMainWindow)
} catch (err) {
errors.push('toggleMain')
}
if (!config.silent) {
if (errors.length === 0) {
mainWindow.webContents.send('APP_SETTING_DONE', {})
} else {
mainWindow.webContents.send('APP_SETTING_ERROR', {
message: 'Failed to apply hotkey: ' + errors.join(' ')
})
}
}
})
nodeIpc.serve(
path.join(app.getPath('userData'), 'boostnote.service'),
function () {
nodeIpc.server.on('connect', function (socket) {
nodeIpc.log('ipc server >> socket joinned'.rainbow)
socket.on('close', function () {
nodeIpc.log('ipc server >> socket closed'.rainbow)
})
})
nodeIpc.server.on('error', function (err) {
nodeIpc.log('Node IPC error'.rainbow, err)
})
}
)
module.exports = nodeIpc
serve() {
fs.mkdirpSync(fs.dappPath(".embark"));
ipc.serve(this.socketPath, () => {});
ipc.server.start();
this.logger.info(`pid ${process.pid} listening on ${this.socketPath}`);
}