🚀 DAY 4 OF LAUNCH WEEK: Introducing GitHub Actions Scanning Support.Learn more →
Socket
Book a DemoInstallSign in
Socket

basic-ipc

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-ipc

IPC library for client-server comms over WebSockets and HTTP

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

node-basic-ipc

NPM version Build Status Gitpod ready-to-code

Node.js real-time client <-> server (between backend and browser) communication library for IPC.

Features:

  • Send and receive JSON objects or binary data
  • Send and receive messages in chunks
  • Request-response pattern

Install

npm install basic-ipc

Usage (Node.js)

Simple example of server and client communication using WebSocket:

const ipc = require('basic-ipc');
const server = ipc.createServer({
  ws: { port: 8091 }
})

server.once('listening', () => {
  const client = ipc.createClient({
    ws: { url: 'ws://localhost:8091' }
  })
  client.once('open', () => {
    client.sendMessage('hello', { world: '!' })
  })
})

server.on('join', async (client) => {
  client.receive('hello', (message) => {
    console.log('Received hello message:', message)
    server.close()
    client.close()
  })
})

Usage (Browser)

In the browser, you can only create clients. basic-ipc exposes a special browser API that only exports code relevant to the client side. You can access it by importing basic-ipc/browser:

const ipc = require('basic-ipc/browser');

API

See the type definitions in index.d.ts for more information.

License

MIT

FAQs

Package last updated on 07 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts