Now that we have created a multifeed, each hypercore
represents a different user in the application. When we replicate with another multifeed peer, we download their feeds and upload ours.
multifeed.feeds()
returns a list of feeds, which are just hypercore objects (ie. they each have a createReadStream()
function)..
multi.ready(function () {
var feeds = multi.feeds()
feeds.forEach(function (feed) {
// feed is a hypercore! (remember reading from hypercores in previous exercises?)
})
})
Using console.log
, write all chat messages to the screen from every hypercore in the multifeed. Have it iterate over all chat messages from all hypercores.
feed.createReadStream(options)
has an option called {live: true}
. If you set this, the stream will stay open and keep emitting new data as it is appended to the hypercore.multi.writer(function (err, feed) {})
.Once you solve this exercise continue to exercise 10a