0.2.0 • Published 8 years ago
multicast-channel v0.2.0
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.
Installing
npm install multicast-channelUsage
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 aBuffer.unpack(buf): Unpack a message from aBuffer. Should return an object withcontentandfrom.
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.