2.1.0 • Published 11 months ago

stream-node-ipc v2.1.0

Weekly downloads
15
License
MIT
Repository
github
Last release
11 months 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

11 months ago

2.0.0

12 months ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago