All Projects → mafintosh → hypercore-multicast-swarm

mafintosh / hypercore-multicast-swarm

Licence: MIT license
Multicast hypercore data over a multicast UDP socket

Programming Languages

javascript
184084 projects - #8 most used programming language

hypercore-multicast-swarm

Multicast hypercore data over a multicast UDP socket

npm install hypercore-multicast-swarm

Still does all the data verification that hypercore normally does etc, it's just multicast!

Usage

const mswarm = require('hypercore-multicast-swarm')

// this will make the hypercore listen for multicast data on the network.
// when it receives a message it doesn't have it will verify it and store it.
const swarm = mswarm(someHypercoreFeed)

someHypercoreFeed.on('download', function (seq, data) {
  console.log('we recevied ' + seq + ' over multicast')
})

// to multicast a hypercore entry
swarm.multicast(42) // multicasts entry 42

API

swarm = mswarm(feed, [options])

Make a hypercore feed join the multicast swarm. Options include:

{
  mtu: 900,
  port: 5007,
  address: '224.1.1.1' // the multicast address to use
}

No hypercore messages are multicast until you call the multicast api below

swarm.multicast(seq, [callback])

Multicast the entry stored at seq in the feed. The callback is called when the underlying udp socket has been flushed.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].