multicast-channel
v0.2.0
Published
A simple communication channel using UDP multicast.
Downloads
7
Maintainers
Readme
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-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 aBuffer
.unpack(buf)
: Unpack a message from aBuffer
. Should return an object withcontent
andfrom
.
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.