npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

multicast-eventer

v1.0.0

Published

An EventEmitter for publishing & subscribing to multicast events across a network

Downloads

4

Readme

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 } = require('multicast-eventer');

// add multicast route to usual network interfaces
setupRoutes();

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 } = require('multicast-eventer');

// add multicast route to usual network interfaces
setupRoutes('wlan0');

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 } = require('multicast-eventer');
const emitter = new MulticastEmitter();

emitter.on('test', data => console.log(`Message from ${data.device}: `, data));
emitter.on('error', console.error);

device-two.js

const { MulticastEmitter } = require('multicast-eventer');
const emitter = new MulticastEmitter();

// the 2nd argument could be an object with anything you want
emitter.emit('test', { message: 'This could be anything' })

Options

  • address (String): the multicast IPv4 address to listen on (valid from 224.0.0.1 to 239.255.255.254). Default is 239.10.10.100.
  • broadcast (Boolean): When set to true, UDP packets may be sent to a local interface's broadcast address. Default is true.
  • loopback (Boolean): When set to true, multicast packets will also be received on the local interface. Default is false.
  • name (String): Name of the device to emit with events. Default is the hostname for the device.
  • port (Number): Destination port. Default is 33333.
  • ttl (Number): Specifies the number of IP hops that a packet is allowed to travel through, specifically for multicast traffic. Default is 128.

Test

For now, the test is basically ensuring the TypeScript source compiles successfully.

$ npm test