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

node-upnp-control-point

v0.0.3

Published

An upnp control point library useful for control, eventing, device and service description

Downloads

12

Readme

node-upnp-control-point

This is a simple UPnP™ control point library, which allows you to control an UPnP™ device and receive events from it.

Functionality

The UPnP™ architecture consists of

  • Discovery: Find UPnP™ devices in the network.
  • Description: Get the capabilities of a discovered device in terms of the device and service description.
  • Control: Invoke actions.
  • Eventing: Get notified when a UPnP™ device changes it status.

The purpose of this module is to provide easy access to description, control and eventing. Discovery is not part of this module at the moment. Fortunately, node-ssdp provides this functionality easily!

Usage

First use node-ssdp to discovery the device description xml file you would like to control, e.g.

var deviceXML = 'http://IP:PORT/description.xml';

Then create an instance

var UPnPControlPoint = require('node-upnp-control-point');
var deviceXML = 'http://IP:PORT/description.xml';
var cp = new UPnPControlPoint(deviceXML);

and retrieve the device description

var UPnPControlPoint = require('node-upnp-control-point');
var deviceXML = 'http://IP:PORT/description.xml';
var cp = new UPnPControlPoint(deviceXML);

var util = require("util");

cp.getDeviceDescriptionParsed(function(err, data) {
  console.log(util.inspect(data, false, null));
});

Assume you want control a media renderer which implements a AVTransportService of version 1, then

var UPnPControlPoint = require('node-upnp-control-point');
var deviceXML = 'http://IP:PORT/description.xml';
var cp = new UPnPControlPoint(deviceXML);

var util = require("util");

cp.getServiceDescriptionParsed('urn:schemas-upnp-org:service:AVTransport:1', function(err, data) {
  console.log(util.inspect(data, false, null));
});

will get you the service description.

You have a media server? Then test

var UPnPControlPoint = require('node-upnp-control-point');
var deviceXML = 'http://IP:PORT/description.xml';

var util = require("util");

var mediaServerCP = new UPnPControlPoint(deviceXML);
mediaServerCP.invokeActionParsed("Browse", {ObjectID: "1", BrowseFlag: "BrowseDirectChildren", Filter: "*", StartingIndex: 0}, 'urn:schemas-upnp-org:service:ContentDirectory:1', function(err, m) {
  console.log(util.inspect(m, false, null));
});

Read the upnp specifications!

You want events?

var UPnPControlPoint = require('node-upnp-control-point');
var deviceXML = 'http://IP:PORT/description.xml';
var cp = new UPnPControlPoint(deviceXML);

cp.createEventListenServer(function() {
  cp.subscribe('urn:schemas-upnp-org:service:AVTransport:1', function(err) {
    if(err) {
      console.log(err);
    } else {
      console.log('subscribed');
    }
  });
});


cp.on('upnpEvent', function(data) {
  console.log(data);
});

make sure to unsubscribe and close the event listen server afterwards.

Alpha Release

Note that this is an alpha release, which means that the API might change and there could be bugs. However, it should be useable right now and if you found any issues or any improvements, please let me know. Feedback is appreciated!

Acknowledgements

This module was inspired by the module node-upnp-device-client from Thibaut Séguy, see git. The API is similar, but not compatible.