# peer-ssdp

> Nodejs implementation of the Simple Service Discovery Protocol

Latest version **0.0.5** (published 2015-07-02) · 0 weekly downloads

## Install

```sh
npm install peer-ssdp
pnpm add peer-ssdp
yarn add peer-ssdp
bun add peer-ssdp
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2015-07-02 |
| First published | 2013-08-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Louay Bassbouss |
| Maintainers | lasakm, lbass |
| Keywords | ssdp, upnp, nsd, network service discovery |

## Links

- npm: https://www.npmjs.com/package/peer-ssdp
- Repository: https://github.com/fraunhoferfokus/peer-ssdp
- Homepage: https://github.com/fraunhoferfokus/peer-ssdp#readme
- Issues: https://github.com/fraunhoferfokus/peer-ssdp/issues
- npm.io page: https://npm.io/package/peer-ssdp

## Recent versions

- 0.0.5 (latest) — 2015-07-02
- 0.0.4 — 2015-06-17
- 0.0.3 — 2015-02-17
- 0.0.2 — 2013-08-02

## README

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](http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf)

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.

```javascript
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](LICENSE).

Contact us at famecontact@fokus.fraunhofer.de

Copyright (c) 2017 Fraunhofer FOKUS

---
_Source: https://npm.io/package/peer-ssdp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
