Skip to content

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

License

Notifications You must be signed in to change notification settings

LzpTec/fast-ipc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@lzptec/fast-ipc

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

Installation

npm

npm i @lzptec/fast-ipc

pnpm

pnpm i @lzptec/fast-ipc

Usage

Server

import { server } from '@lzptec/fast-ipc';

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

            return {
                data: data
            };
        });

Client

import { client } from '@lzptec/fast-ipc';

const ipcClinet = new client('example');

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

const msg = await ipcClinet.send('ping', null);
console.log(msg); 
// pong!

const event = await ipcClinet.send('event', [1, 2, 3, 'testing']);
console.log(event);

const asyncEvent = await ipcClinet.send('asyncEvent', 123);
console.log(asyncEvent);
// { data: 123 }

Original

The original project(fast-ipc) hasn't been updated in the last 2 years, so I created this fork and updated the library

Diferences

A new config parameter has been added to the client and server constructors.

The library is now promise-based.

Notes

Documentation will be updated over time.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published