Skip to content

Fast & simple IPC (Inter-Process Communication) server/client written on native net module

License

Notifications You must be signed in to change notification settings

scrwdrv/fast-ipc

Repository files navigation

fast-ipc

Fast & simple IPC (Inter-Process Communication) server/client build on native net module

Installation

npm i fast-ipc

Usage

Server

import { server } from 'fast-ipc';

const ipcServer =
    new server('example')
        .on('msg', (req) => {
            console.log(req);
            //[1, 2, 3, 4, 5]
        })
        .on('ping', (req, res) => {
            res('pong!');
        })
        .on('event', (req, res) => {
            res({
                data: req,
                timestamp: Date.now()
            });
        });

Client

import { client } from 'fast-ipc';

const ipcClinet = new client('example');

ipcClinet.send('msg', [1, 2, 3, 4, 5]);

ipcClinet.send('ping', [], (msg) => {
    console.log(msg);
    //pong!
});

ipcClinet.send('event', [1, 2, 3, 'testing'], (msg) => {
    console.log(msg);
    //{ data: [ '1', '2', '3', 'testing' ], timestamp: 1577025604487 }
});

About

Fast & simple IPC (Inter-Process Communication) server/client written on native net module

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published