在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ipfs-shipyard/ipfs-pubsub-peer-monitor开源软件地址:https://github.com/ipfs-shipyard/ipfs-pubsub-peer-monitor开源编程语言:JavaScript 100.0%开源软件介绍:ipfs-pubsub-peer-monitor
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. Usageconst PeerMonitor = require('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)) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论