Creates a room based on an IPFS pub-sub channel. Emits membership events, listens for messages, broadcast and direct messeges to peers.
$ npm install ipfs-pubsub-room
const Room = require('ipfs-pubsub-room')
const ipfs = new IPFS()
const room = Room(ipfs, 'room-name')
ipfs
: IPFS object. Must have pubsub activatedroomName
: string, global identifier for the roomoptions
: object:pollInterval
: interval for polling the pubsub peers, in ms. Defaults to 1000.
const room = Room(ipfs, 'some-room-name')
Broacasts message (string or buffer).
Sends message (string or buffer) to peer.
Leaves room, stopping everything.
Returns an array of peer identifiers (strings).
Returns a boolean indicating if the given peer is present in the room.
Listens for messages. A message
is an object containing the following properties:
from
(string): peer iddata
(Buffer): message content
Once a peer has joined the room.
Once a peer has left the room.
ISC