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

@patrickkfkan/peer-ssdp

v0.1.0

Published

Nodejs implementation of the Simple Service Discovery Protocol

Downloads

67

Readme

Forked from https://github.com/fraunhoferfokus/peer-ssdp with the following changes:

v0.1.0:

  • Add bindToInterfaces and bindToAddresses options.
  • Based on upstream v0.0.5.

Everything else is the original author's work.

peer-ssdp

peer-ssdp is a simple Node.js module implementing the Simple Service Discovery Protocol SSDP as described in the UPnP Device Architecture specification, Section 1

Setup

  • use npm install peer-ssdp to install the module.
  • run example with node node_modules/peer-ssdp/test/ssdp-test.js

Usage

Peer is an EventEmitter so you can use the common EventEmitter API to subscribe to specific events.

var ssdp = require("peer-ssdp");
var peer = ssdp.createPeer();
var interval;
/**
 * handle peer ready event. This event will be emitted after `peer.start()` is called.
 */
peer.on("ready",function(){
	// handle ready event
	// send ssdp:alive messages every 1s
	// {{networkInterfaceAddress}} will be replaced before
	// sending the SSDP message with the actual IP Address of the corresponding
	// Network interface. This is helpful for example in UPnP for LOCATION value
	interval = setInterval(function(){
		peer.alive({
			ST: "upnp:rootdevice",
			SERVER: "...",
			ST: headers.ST,
			USN: "...",
			LOCATION: "http://{{networkInterfaceAddress}}/device-desc.xml",
		});
	}, 1000);
	// shutdown peer after 10 s and send a ssdp:byebye message before
	setTimeout(function(){
		clearInterval(interval);
		// Close peer. Afer peer is closed the `close` event will be emitted.
		peer.close();
	}, 10000);
});

// handle SSDP NOTIFY messages. 
// param headers is JSON object containing the headers of the SSDP NOTIFY message as key-value-pair. 
// param address is the socket address of the sender
peer.on("notify",function(headers, address){
	// handle notify event
});

// handle SSDP M-SEARCH messages. 
// param headers is JSON object containing the headers of the SSDP M-SEARCH message as key-value-pair. 
// param address is the socket address of the sender
peer.on("search",function(headers, address){
	// handle search request
	// reply to search request
	// Also here the {{networkInterfaceAddress}} will be replaced before
  // sending the SSDP message with the actual IP Address of the corresponding
  // Network interface.
	peer.reply({
		ST: "upnp:rootdevice",
		SERVER: "...",
		ST: headers.ST,
		USN: "...",
		LOCATION: "http://{{networkInterfaceAddress}}/device-desc.xml",
	},address);
});

// handle SSDP HTTP 200 OK messages. 
// param headers is JSON object containing the headers of the SSDP HTTP 200 OK  message as key-value-pair. 
// param address is the socket address of the sender
peer.on("found",function(headers, address){
	// handle found event
});

// handle peer close event. This event will be emitted after `peer.close()` is called.
peer.on("close",function(){
	// handle close event
});

// Start peer. Afer peer is ready the `ready` event will be emitted.
peer.start();

License

GNU Lesser General Public License v3.0, for more details please refer to the LICENSE file.

Contact us at [email protected]

Copyright (c) 2017 Fraunhofer FOKUS