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

rxprotoplex-rpc

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxprotoplex-rpc

A library for managing RPC connections using RxJS and Protoplex.

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

rxprotoplex-rpc

Overview

connectAndRpc$ and listenAndConnectionAndRpc$ are utility functions designed for establishing connections and creating RPC (Remote Procedure Call) instances from streams in a reactive programming context. These functions are built using RxJS and leverage JSON encoding for data transmission over specified channels.

Usage

Importing the Functions

To use connectAndRpc$ and listenAndConnectionAndRpc$, make sure to import them from your module:

import { connectAndRpc$, listenAndConnectionAndRpc$ } from 'rxprotoplex-rpc';

connectAndRpc$

Description

Establishes a connection to the provided plex object, sets up a communication channel with JSON encoding, and returns an observable that emits an RPC instance created from the stream.

Syntax
const rpc$ = connectAndRpc$(plex, channel);
Parameters
  • plex (Object): The connection object representing the peer or signaling entity.
  • channel (Uint8Array, optional): The channel for the connection, defaulting to CHANNEL (b4a.from("$RPC$")).
Returns
  • Observable: An observable that emits an RPC instance created from the connected stream.
Example
connectAndRpc$(plex).subscribe(rpc => {
    // Use the rpc instance here
    rpc.request.someMethod().then(response => console.log(response));
});

listenAndConnectionAndRpc$

Description

Listens for connections on the given plex object, sets up a communication channel with JSON encoding, and returns an observable that emits an RPC instance created from the connected stream.

Syntax
const rpc$ = listenAndConnectionAndRpc$(plex, channel);
Parameters
  • plex (Object): The connection listener object representing where connections are managed.
  • channel (Uint8Array, optional): The channel for listening and connection, defaulting to CHANNEL (b4a.from("$RPC$")).
Returns
  • Observable: An observable that emits an RPC instance created from the connected stream.
Example
listenAndConnectionAndRpc$(plex).subscribe(rpc => {
    // Use the rpc instance here
    rpc.request.anotherMethod().then(result => console.log(result));
});

Constants

CHANNEL

A predefined constant for channel identification:

export const CHANNEL = b4a.from("$RPC$");

License

This module is licensed under MIT License.


For more details on how to extend or modify these functions, refer to the code comments or inline documentation.

Keywords

FAQs

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