New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@peerbit/rpc

Package Overview
Dependencies
Maintainers
0
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerbit/rpc

RPC calls for peers

  • 5.0.18
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by237.1%
Maintainers
0
Weekly downloads
 
Created
Source

RPC

This module contains a communication protocol for generic request-and-response communication. This module can be used as a component in other modules. Documents, DString for examples

How it works

@variant("hello")
class Hello {
    
    // add payload properties here
    constructor() {
       
    }
}

@variant("world")
class World {
    
    // add payload properties here
    constructor() {
       
    }
}

@variant("rpc-test")
class RPCTest extends Program {

    @field({ type: RPC })
    rpc: RPC<Hello, World>;

    async setup(): Promise<void> {
        await this.rpc.setup({
            responseType: Hello,
            queryType: World,
            context: this,
            responseHandler: (resp, from) => {
                return resp;
            },
        });
    }
}

// later (assume that some other peers also opens the RPCTest program)
const peer = await Peerbit.create ()
const rpcTest = peer.open(new RPCTest());

await rpcTest.rpc.request( new Hello(), (resp) => { console.log(resp)  })

Visualized

p1

p1

See Document store and Clock Service as implementation examples.

FAQs

Package last updated on 07 Nov 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

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