0.1.0 • Published 2 years ago
ipfs-pubsub-peer-monitor v0.1.0
ipfs-pubsub-peer-monitor
Know when peers are joining and leaving an IPFS PubSub topic
ipfs-pubsub-peer-monitor
listens on a IPFS PubSub topic and emits an event when a peer joins or leaves the topic.
This module is based on ipfs-pubsub-room that can provide the same functionality. It contains extra features that are not necessary for purely wanting to know joins/leaves, so this module was created to do that and only that.
Usage
import PeerMonitor from 'ipfs-pubsub-peer-monitor'
// Get an IPFS instance somehow
const ipfs = ...
// Topic to monitor
const topic = 'abc'
// Make sure to subscribe to the channel before monitoring it!
ipfs.pubsub.subscribe(topic, (message) => {}, (err, res) => {})
// Pass an IPFS pubsub object and the topic to the monitor
const topicMonitor = new PeerMonitor(ipfs.pubsub, topic)
// When a peer joins the topic
topicMonitor.on('join', peer => console.log("Peer joined", peer))
topicMonitor.on('leave', peer => console.log("Peer left", peer))
topicMonitor.on('error', e => console.error(e))
0.1.1-100bdbe.0
2 years ago
0.1.1-6ae7b21.0
2 years ago
0.1.0
2 years ago
0.0.11-ef4183e.0
2 years ago
0.0.10
4 years ago
0.0.9
5 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago