multicast-eventer
An EventEmitter for publishing & subscribing to multicast events across a network.
Installation
$ npm install multicast-eventer
Setup
If you're setting up your device for the first time and running Linux, there is a handy setupRoutes
function included in the package to set up the multicast routes.
setup.js
const setupRoutes = ; // add multicast route to usual network interfaces;
Or if you know what network interface you'll be using, i.e eth0
for ethernet or wlan0
for WiFI, you can pass that as an argument to setupRoutes
.
setup.js
const setupRoutes = ; // add multicast route to usual network interfaces;
Usage
You can use this package just like any other EventEmitter, expect the events will span devices instead of the local program:
device-one.js
const MulticastEmitter = ;const emitter = ; emitter;emitter;
device-two.js
const MulticastEmitter = ;const emitter = ; // the 2nd argument could be an object with anything you wantemitter
Options
- address (
String
): the multicast IPv4 address to listen on (valid from 224.0.0.1 to 239.255.255.254). Default is239.10.10.100
. - broadcast (
Boolean
): When set to true, UDP packets may be sent to a local interface's broadcast address. Default istrue
. - loopback (
Boolean
): When set to true, multicast packets will also be received on the local interface. Default isfalse
. - name (
String
): Name of the device to emit with events. Default is the hostname for the device. - port (
Number
): Destination port. Default is33333
. - ttl (
Number
): Specifies the number of IP hops that a packet is allowed to travel through, specifically for multicast traffic. Default is128
.
Test
For now, the test is basically ensuring the TypeScript source compiles successfully.
$ npm test