2.1.0 • Published 2 years ago

stream-node-ipc v2.1.0

Weekly downloads
15
License
MIT
Repository
github
Last release
2 years ago

stream-node-ipc

node-ipc as Duplex streams

Usage

server

import { getServer, NodeIpcServerDuplex } from 'stream-node-ipc';

const someNodeIPCConfigToOverride = { maxConnections: 12 };
// first parameter here is node-ipc `appspace` parameter
const ipcClient = getServer('magne4000-test-worker', someNodeIPCConfigToOverride);

const newClientConnection = (_data: Buffer, socket: Socket) => {
  // Direct bi-directionnal connection between a client (socket) and this server
  // using node-ipc
  const duplex = new NodeIpcServerDuplex(ipcClient, socket);
  duplex.write(...); // writes to the client via node-ipc
  duplex.on('data', (...) => {
    // Callback called when the client sends data via node-ipc
  })
};

// catch first connection for each client in some way
ipcClient.on('data', newClientConnection);

client

import { getClient, NodeIpcClientDuplex } from 'stream-node-ipc';

const someNodeIPCConfigToOverride = { logger: console.log };
// first parameter here is node-ipc `appspace` parameter
const ipcClient = getClient('magne4000-test-worker', 'myClientId', someNodeIPCConfigToOverride);

const duplex = new NodeIpcClientDuplex(ipcClient);
duplex.write(...); // writes to the server via node-ipc
duplex.on('data', (...) => {
  // Callback called when the server sends data via node-ipc
})
2.1.0

2 years ago

2.0.0

2 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago