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

@rsksmart/rif-communications-pubsub

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsksmart/rif-communications-pubsub

PubSub module

  • 0.1.0-dev.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-86.36%
Maintainers
2
Weekly downloads
 
Created
Source

RIF Communications PubSub

CircleCI Dependency Status standard-readme compliant js-standard-style Managed by tAsEgir

Library for creating a PubSub room with libp2p

This project extends the ipfs-pubsub-room, rewriting it in typescript and adding libp2p node.

Table of Contents

Install

npm

> npm install @rsksmart/rif-communications-pubsub

WARNING: This package still have not been released!

Usage

Example of usage:

import { Room, createLibP2P } from '@rsksmart/rif-communications-pubsub'

const libp2p = await createLibP2P()
const room = createRoom(libp2p, 'my_topic')

room.on('peer:joined', (peer: string) => {
  console.log('Peer joined the room ', peer)
})

room.on('peer:left', (peer: string) => {
  console.log('Peer left the room', peer)
})

room.on('message', ({from, data}: {from: string, data: Buffer}) => {
  console.log('New message from ', peer, ' content ', data)
})

room.on('unsubscribed', () => {
  console.log('Unsubscribed from the room room')
})

API

const libp2p = await createLibP2P()

const room = createRoom(libp2p, topic) // Creates room with specific topic
room.leave() // Leave the room, stop libp2p
async room.broadcast(message: string | buffer) // Send message to the room

room.peerId
room.peers
room.hasPeer(cid: string)

room.on('peer:joined', (cid: string) => {})
room.on('peer:left', (cid: string) => {})
room.on('message', (message: {from: string, data: Buffer, to?: string}) => {})
room.on('unsubscribed', () => {})

License

MIT

Keywords

FAQs

Package last updated on 19 Aug 2020

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