Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blue-rpc-protocol

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blue-rpc-protocol

A fast RPC protocol that uses WebSockets and MessagePack

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

blue-rpc-protocol

BlueRPC is a fast RPC protocol that uses WebSockets and MessagePack. It solves real-world problems and is very easy to use.

In BlueRPC, streams are first-class data types. You can send streams just like any other value, and BlueRPC automatically handles things like cancellation and backpressure.

Since streams are just regular values, you can easily mix them with structured data, unlike HTTP (where you'd need to use headers or "multipart/form-data" for structured data) or gRPC (where there's no way to directly represent a byte stream) or JSON-RPC (which doesn't support streaming).

Here are its features:

  • Byte streams (first class data type), useful for efficiently piping large payloads such as files.
  • Object streams (first class data type), useful for representing pub-sub subscriptions and observables.
  • Universal web-compatibility, because of WebSockets.
  • Low bandwidth, because of MessagePack, WebSockets, and automatic compression.
  • Simple RPC-style interface.
  • Built-in support for cancelling RPC calls and streams.
  • "Notifications", inspired by JSON-RPC, for pushing lightweight events to the server.
  • Encodes strings, binary (Buffer or Uint8Array), objects, arrays, floats, integers (BigInt), booleans, null, Error, and streams (stream.Readable or ReadableStream).

BlueRPC can be implemented in any general-purpose programming language. This repository contains a specification and a reference implementation for JavaScript (compatible with Node.js and browsers).

Installation

npm install blue-rpc-protocol

Requires Node.js v16.x.x or later, or any modern browser.

Usage

Server example
const http = require('http');
const BlueRPC = require('blue-rpc-protocol');

const methods = {
    echo: (param) => {
        return param;
    }
};

await BlueRPC.listen({
    methods,
    server: http.createServer(),
    logger: console.log
});
Client example
const BlueRPC = require('blue-rpc-protocol');

const client = BlueRPC.createClient('ws://localhost');

const result = await client.invoke('echo', 'foo');
console.log('result:', result); // => "result: foo"

Documentation

License

MIT

FAQs

Package last updated on 03 Mar 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc