How to use the node-ipc.serve function in node-ipc

To help you get started, we’ve selected a few node-ipc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ahkohd / switch / src / Interprocess.ts View on Github external
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');
github Mayank1791989 / gql / src / cli / rpc / Server.js View on Github external
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) => {
github BoostIO / Boostnote / browser / main / lib / ipc.js View on Github external
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.
github ahkohd / switch / build / Interprocess.js View on Github external
        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();
github enqueuer-land / enqueuer / src / ipc / ipc-uds.ts View on Github external
start(ipcCommunicatorCallback: IpcCommunicatorCallback): void {
        console.log("starting ipc-uds");

        ipc.serve(() => this.onConnect());
        ipc.server.start();
    }
github luminati-io / luminati-proxy / bin / lum_node_index.js View on Github external
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});
github electrode-io / electrode-native / ern-core / src / BundleStoreEngine.ts View on Github external
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()
  }
github BoostIO / Boostnote / lib / ipcServer.js View on Github external
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
github embark-framework / embark / src / lib / core / ipc.js View on Github external
serve() {
    fs.mkdirpSync(fs.dappPath(".embark"));
    ipc.serve(this.socketPath, () => {});
    ipc.server.start();

    this.logger.info(`pid ${process.pid} listening on ${this.socketPath}`);
  }

node-ipc

A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis