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'
const ipfs = ...
const topic = 'abc'
ipfs.pubsub.subscribe(topic, (message) => {}, (err, res) => {})
const topicMonitor = new PeerMonitor(ipfs.pubsub, 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))