How to use the node-ipc.connectToNet 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 alibaba / ice / tools / ice-scripts / lib / utils / iceworksClient.js View on Github external
const ipc = require('node-ipc');

ipc.config.id = 'ice-sdk';
ipc.config.silent = true;
let connected = false;

const ON_ICEWORKS = typeof process.env.ICEWORKS_IPC !== 'undefined';

if (ON_ICEWORKS) {
  ipc.connectToNet('iceworks', () => {
    ipc.of.iceworks.on('connect', () => {
      connected = true;
      console.log('iceworks ipc 链接成功');
    });
    ipc.of.iceworks.on('disconnect', () => {
      connected = false;
      ipc.log('disconnected from iceworks');
    });
  });
}

module.exports = {
  available: ON_ICEWORKS,
  send: (data) => {
    // 尽在可用的环境下发送消息,scoket 的链接在任何状态下都可
    if (connected && ON_ICEWORKS) {
github Mostafa-Samir / klyng / tests / specs / beacon / beacon-remote.specs.js View on Github external
it('responds to KEY-EXT:PARAMS and creates a shared secret', function(done) {
        ipc.connectToNet('auth_socket', '127.0.0.1', 7777, function() {
            var dhObj = cs.diffieHellman();
            ipc.of.auth_socket.emit('KEY-EXT:PARAMS', {
                prime: dhObj.prime,
                key: dhObj.publicKey
            });

            ipc.of.auth_socket.on('KEY-EXT:PUBLIC', function(data) {
                ipc.of.auth_socket.klyng_secret = dhObj.computeSecret(data.key);
                var welcomeMsg = cs.verify(data.cipherWelcome, ipc.of.auth_socket.klyng_secret);

                expect(welcomeMsg).to.equal("Hello from Beacon's TCP Server!");
                done();
            })
        });
    });
github Mostafa-Samir / klyng / tests / specs / beacon / beacon-remote.specs.js View on Github external
it('refuses a SIGNAL:DONE message on an unothorized socket', function(done) {
        ipc.connectToNet('nauth_socket', '127.0.0.1', 7777, function() {
            ipc.of.nauth_socket.emit('SIGNAL:DONE');
            ipc.of.nauth_socket.on('DONE:ACK', function(data) {
                expect(data.status).to.be.false;
                expect(data.error).to.equal("Unauthorized");
                done();
            });
        });
    });
github azuqua / notp / bin / cli.js View on Github external
"If force is passed, the gossip processor on this node " +
      "won't wait for current message streams to be processed " +
      "before executing this command.")
  .option("-f, --force", forceStr)
  .action(function (args, cb) {
    const nodes = parseNodeList(args.nodes);
    client.send("mremove", {
      force: args.options.force,
      nodes: nodes
    }, cb);
  });

console.log("Connecting to IPC server on node: %s, host: %s, port: %s", argv.I, argv.H, argv.p);
ipc.config.silent = true;
ipc.config.sync = true;
ipc.connectToNet(argv.I, argv.H, argv.p, () => {
  client = new Client(ipc, argv.I, argv.H, argv.p, argv.a);
  client.start();
  client.once("connect", () => {
    if (argv._.length === 0) {
      vorpal
        .delimiter("> ")
        .show();
    } else {
      vorpal.exec(argv._, function (err, res) {
        client.stop();
        if (err) {
          process.exit(1);
        } else {
          process.exit(0);
        }
      });
github havardh / workflow / packages / workflow-server / src / client.js View on Github external
export async function apply(path, args) {
  ipc.connectToNet('workflow-server', () => {
    const server = ipc.of['workflow-server'];

    server.on('connect', () => {
      server.emit('workflow.apply', JSON.stringify({ path, args }));

      ipc.disconnect('workflow-server');
    });
  });
}
github kuzzleio / kuzzle / lib / services / ipc.js View on Github external
function connect() {
  var deferred = q.defer();

  if (!ipc.of[this.serverName]) {
      ipc.connectToNet(this.serverName, this.host, this.port, function () {
        ipc.of[this.serverName].on('connect', function () {
          deferred.resolve('Connected to ', this.serverName);
        }.bind(this));
      }.bind(this));
  }
  else {
    deferred.resolve('Already connected to server ', this.serverName);
  }

  return deferred.promise;
}

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 3 months ago

Package Health Score

71 / 100
Full package analysis