0.2.0 • Published 7 years ago

multicast-channel v0.2.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

multicast-channel

A simple communication channel using UDP multicast. Node.js only. Send an receive anything JSON.stringify-able.

Similar to multicast. The code is heavily inspired by multicast-dns.

npm version build status ISC-licensed chat on gitter

Installing

npm install multicast-channel

Usage

const createChannel = require('multicast-channel')

const channel = createChannel({name: 'derhuerst'})

channel.on('error', console.error)
channel.on('message', (msg, from) => {
	console.log('got a message!', msg, from)
})

channel.on('open', () => {
	channel.send({hello: 'friends!'})
})

API

createChannel([opt])

opt may have the following keys:

  • name: The user name to send messages with.
  • pack(content, from): Pack a message into a Buffer.
  • unpack(buf): Unpack a message from a Buffer. Should return an object with content and from.

Contributing

If you have a question or have difficulties using multicast-channel, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.