Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((res, rej) => {
// Note: we give pushpin a couple seconds to handle the message
const timer = setTimeout(() => {
ipc.disconnect('renderer')
res({ type: 'Failed', details: 'Timed out.' })
}, 2500)
ipc.connectTo('renderer', WEBCLIPPER_SOCKET_LOCATION, () => {
ipc.of.renderer.on('connect', () => {
ipc.of.renderer.emit('clipper', msg)
ipc.of.renderer.on('renderer', (msg) => {
res(msg)
ipc.disconnect('renderer')
clearTimeout(timer)
})
})
})
})
}
return new Promise((resolve, reject) => {
const serverName = ipc.config.id;
ipc.connectTo(serverName, () => {
const server = ipc.of[serverName];
// connected and emit method
server.on('connect', () => {
ipc.log(`connected to "${serverName}"`);
// call method on server
server.emit(method, input);
});
// listen for method response
server.on(method, ({ error, response }) => {
// receive server respons
ipc.disconnect(serverName); // disconnect client to server
ipc.log(`${serverName}@${method}:response`, error, response);
resolve(response); // return response
});
done();
}
});
ipc.of['embark'].on('disconnect',function() {
self.connected = false;
ipc.disconnect('embark');
// we only want to trigger the error callback the first time
if (!connectedBefore && !alreadyDisconnected) {
alreadyDisconnected = true;
done(new Error("no connection found"));
}
});
}
ipc.connectTo('embark', this.socketPath, connecting);
}
appProc.stdout.on("data", data => {
let stringifiedData = data.toString();
process.stdout.write(stringifiedData);
if (stringifiedData.match(new RegExp(process.env.WAIT_FOR_MESSAGE, "i"))) {
console.log("Restarting cypress tests!");
const cypressWatcherId = "cypress-rerun-with-app";
ipc.connectTo(cypressWatcherId, function() {
ipc.of[cypressWatcherId].emit("message", "RESTART");
});
}
});
return new Promise(resolve => {
const onMessageCallbacks = [];
ipc.connectTo(serverID, () => {
ipc.of[serverID].on('connect', () => {
const initMessage = makeMessage({
messageType: MESSAGE_TYPES.INITIALIZE,
});
ipc.of[serverID].emit(workerID, initMessage);
});
ipc.of[serverID].on(workerID, data => {
onMessageCallbacks.forEach(cb => cb(data));
});
resolve({
send: message => ipc.of[serverID].emit(workerID, message),
onMessage: fn => {
onMessageCallbacks.push(fn);
},
pyshell.on('message', (message) => {
console.log('Python output:', message);
})
var channel = null;
ipc.config.id = 'ipc';
ipc.config.socketRoot = '/tmp/';
ipc.config.appspace = 'app.';
ipc.config.silent = true;
ipc.config.rawBuffer = true;
ipc.config.retry= 1500;
var callback = null;
//TODO: this should be put into an init function
ipc.connectTo(
'main',
function(){
ipc.of.main.on(
'connect',
function(){
ipc.log('## connected to main ##', ipc.config.delay);
channel = ipc.of.main;
}
);
ipc.of.main.on(
'data',
function(data) {
callback && callback();
}
)
}
import ConfigManager from './ConfigManager'
const nodeIpc = require('node-ipc')
const { remote, ipcRenderer } = require('electron')
const { app } = remote
const path = require('path')
nodeIpc.config.id = 'main'
nodeIpc.config.retry = 1500
nodeIpc.config.silent = true
nodeIpc.connectTo(
'node',
path.join(app.getPath('userData'), 'boostnote.service'),
function () {
nodeIpc.of.node.on('error', function (err) {
console.error(err)
})
nodeIpc.of.node.on('connect', function () {
ipcRenderer.send('config-renew', {config: ConfigManager.get()})
})
nodeIpc.of.node.on('disconnect', function () {
return
})
}
)
module.exports = nodeIpc
return new Promise((resolve, reject) => {
ipc.connectTo(name, () => {
ipc.of[name].on('error', () => {
ipc.disconnect(name);
resolve(false);
});
ipc.of[name].on('connect', () => {
ipc.disconnect(name);
resolve(true);
});
});
});
}
if (this._child) {
this._child.kill();
}
this._child = exec(`node "${path.join(__dirname, 'jspm-worker.js')}" ${this._workerId}`);
this._child.stderr.on('data', error => {
//immediate death
throw new Error(error);
});
ipc.connectTo(this._workerId, () => {
ipc.of[this._workerId].on('connect', () => {
defer.resolve();
});
ipc.of[this._workerId].on('result', this._resultHandler.bind(this));
});
return defer.promise;
}