node-sync-ipc
node-sync-ipc
is a tiny library making it possible for node processes to send synchronous message to other processes. It can block the client side process until the server make a response.
Install
npm install node-sync-ipc
Usage
Server side:
// server.js const SyncIPCServer = SyncIPCServer; // pipe File// on Unix based systems, pipe file should be a sock file path// on Windows, pipe should be named pipes// const pipeFile = "\\\\.\\pipe\\somePipeName"; // <- windowsconst pipeFile = path; const server = pipeFile; server; server; //stop server when not needed//server.stop()
Client Side:
// client.js const SyncIPCClient = SyncIPCClient; // pipe File to connect toconst serverHandle = path; const client = serverHandle; // will log "echo content echo content" in console console;
Attention
Data should be serializable
Data to be transferred will be serialized and deserialized in the format of JSON. Error will be thrown if data is not serializable by JSON.stringify
.
Also class information will be lost during the communication.
Electron && NW.js
This module has c++ add-ons, so you have to rebuild it to use it in Electron.
Copyright
Copyright (c) 2018 Hang Ma. See LICENSE for details.