npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@edgematrixjs/rtc

v1.0.7

Published

edgematrixjs rtc

Downloads

14

Readme

@edgematrixjs/rtc

This project is built on top of the edgematrixjs-packages and provides commonly used APIs such as "Send Node [Methods]", "Send Message", "Create a Subject", and "Subscribe to a Subject."

It uses "@edgematrixjs/tx" for encoding and signing communication data.

It utilizes "@edgematrixjs/http" for HTTP communication. However, you can also use your own implementation by implementing the postJSON() method.

For WebSocket communication, it relies on "@edgematrixjs/socket." You can also use a custom implementation by implementing the send(), removeMessageListener(), and addMessageListener() methods.

Install

npm install --save @edgematrixjs/rtc

Dependencies

{
  "@edgematrixjs/tx": "^1.0.0",
  "@edgematrixjs/util": "^1.0.0",
  "@edgematrixjs/http": "^1.0.0",
  "@edgematrixjs/socket": "^1.0.0"
}

Example

Send Node Api

import { Http } from '@edgematrixjs/http';
import { RTC } from '@edgematrixjs/rtc';
const emHttp = new Http({ baseURL: httpsUrl });
const rtc = new RTC();
const path = '/sdapi/v1/txt2img';
const method = 'POST';
const headers: any[] = [];
const body = { prompt: 'cat', width: 80, height: 80 };
const { _result, _desc, data } = await rtc.sendNodeApi(
  { chainId, nodeId, path, method, headers, body },
  privateKey,
  emHttp
);
if (_result !== 0) {
  throw new Error(_desc);
}
//the formatted implementing follow "test/node.spec.tx"
const newData = formatted(data);
const insideResponse = newData.result?.response;
const images = insideResponse?.images || [];
st.equal(images.length, 1, `send node api success`);

Create Subject

import { Http } from '@edgematrixjs/http';
import { RTC } from '@edgematrixjs/rtc';
const chatId = 2;
const privateKey = '';
const httpsUrl = 'https://oregon.edgematrix.xyz';
const emHttp = new Http({ baseURL: httpsUrl });
const rtc = new RTC();
const { _result, hash } = await rtc.createSubject(chainId, privateKey, emHttp);
//_result === 0 is success, the 'hash' is subject

Subscribe Subject

import { EmSocket } from '@edgematrixjs/socket';
import { RTC } from '@edgematrixjs/rtc';
//connect method implement follow in test/index.spec.ts
const wssUrl = 'wss://oregon.edgematrix.xyz/edge_ws';
const handleAction = ({ action, event }) => {};
const { _result: _socketResult, emSocket, event } = await connect({ network: wssUrl, callback: handleAction });
if (_socketResult !== 0) {
  throw new Error('socket is error');
}
const rtc = new RTC();
const chatId = 2;
const application = 'edge_chat';
const subject = 'Your Subject';
const content = 'Your Content';
const params = { subject, application, content, chainId };
const { _result } = await rtc.subscribe(params, privateKey, emSocket);
//_result === 0 is success

Send Message

import { Http } from '@edgematrixjs/http';
import { RTC } from '@edgematrixjs/rtc';
const httpsUrl = 'https://oregon.edgematrix.xyz';
const emHttp = new Http({ baseURL: httpsUrl });
const rtc = new RTC();
const params = {
  subject: globalSubject,
  application: 'edge_chat',
  content: JSON.stringify({ data: 'test send message' }),
  //When the "To" parameter is empty, everyone who subscribed to the subject will receive your message
  //to?: {TargetPublicKey},
  chainId,
};
const { _result } = await rtc.sendMessage(params, privateKey, emHttp);
//_result === 0 is success

The more used in test/index.spec.ts

npm run test:node
or
npm run test:browser

API

constructor(config?: RTCConfig)

Initializes the RTC object with an optional configuration object.

subscribe(params: SubscribeParams, privateKey: string, emSocket: EmSocket): Promise<CreateSubjectResp>

Subscribes to a subject for real-time communication.

  • Parameters:
    • params: An object containing the subject, content, application, and chainId.
    • privateKey: The private key used for signing the transaction.
    • emSocket: The EmSocket object for communication.
  • Returns: A promise that resolves with the response containing the result and hash of the subscription.

sendSocketMessage(params: SubscribeParams, privateKey: string, emSocket: EmSocket)

Sends a message using the socket.

  • Parameters:
    • params: An object containing the subject, content, application, and chainId.
    • privateKey: The private key used for signing the transaction.
    • emSocket: The EmSocket object for communication.

createSubject(chainId: number, privateKey: string, http: Http): Promise<any>

Creates a new subject for real-time communication.

  • Parameters:
    • chainId: The chain ID.
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: A promise that resolves with the response containing the result and data of the subject creation.

getTelegramCount(chainId: number, privateKey: string, http: Http): Promise<any>

Retrieves the telegram count for a given chain and address.

  • Parameters:
    • chainId: The chain ID.
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: A promise that resolves with the response containing the result and nonce.

getTelegramReceipt(hash: string, http: Http): Promise<any>

Retrieves the receipt of a telegram message.

  • Parameters:
    • hash: The hash of the telegram message.
    • http: The Http object for making HTTP requests.
  • Returns: A promise that resolves with the response containing the result, hash, and data of the telegram receipt.

sendMessage(messageParams: MessageParams, privateKey: string, http: Http): Promise<any>

Sends a message using HTTP.

  • Parameters:
    • messageParams: An object containing the subject, content, to, application, and chainId.
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: A promise that resolves with the response containing the result of the message sending.

sendNodeApi({ chainId, nodeId, path, method, headers, body }: NodeParameters, privateKey: string, http: Http): Promise<RawTelegramResponse>

Calling the internal API of the node

  • Parameters:
    • NodeParameters: chainId:number, nodeId:number, path:'string', method:'string', headers:[], body,
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: RawTelegramResponse {_result,_desc?,data}

sendNodeInfo({ chainId, nodeId}: NodeParameters, privateKey: string, http: Http): Promise<RawTelegramResponse>

Query the "Info" of the node

  • Parameters:
    • NodeParameters: chainId:number, nodeId:number
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: RawTelegramResponse {_result,_desc?,data}

sendNodeIdl({ chainId, nodeId }: NodeParameters, privateKey: string, http: Http): Promise<RawTelegramResponse>

Query the "IDL" of the node

  • Parameters:
    • NodeParameters: chainId:number, nodeId:number
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: RawTelegramResponse {_result,_desc?,data}

sendNodeEcho({ chainId, nodeId, body }: NodeParameters, privateKey: string, http: Http): Promise<RawTelegramResponse>

Calling the "echo" of the node

  • Parameters:
    • NodeParameters: chainId:number, nodeId:number, body:string,
    • privateKey: The private key used for signing the transaction.
    • http: The Http object for making HTTP requests.
  • Returns: RawTelegramResponse {_result,_desc?,data}