How to use the node-ssdp.Client function in node-ssdp

To help you get started, we’ve selected a few node-ssdp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dhleong / wemore / test-discover.js View on Github external
#!/usr/bin/env node

// var wemore = require('./');
// wemore.Discover()
// .on('device', function(device) {
//     if (device.friendlyName == 'television' 
//             || device.friendlyName == 'playstation') {
//         console.log(device);
//     }
// });

var SsdpClient = require('node-ssdp').Client
  // , BELKIN_CONTROLLEE = "urn:Belkin:device:controllee:1"
  , BELKIN_CONTROLLEE = "urn:Belkin:device:**"
  ;
var client = new SsdpClient({logLevel: 'TRACE'});
client.on('response', function(resp) {
    console.log(resp);
});
client.search(BELKIN_CONTROLLEE);
github dmooney65 / fmradio / devfiles / ssdpSearch.js View on Github external
var Client = require('node-ssdp').Client;

let client = new Client();

let getRenderers = () => {
    let servers = [];

    let findRenderers = () => {
        var parent = document.getElementById('divMain');
        client.on('response', function (headers, statusCode, rinfo) {
            console.log('Got a response to an m-search.');
            var newDiv = document.createElement('div');
            var newContent = document.createTextNode(headers['LOCATION']);
            newDiv.appendChild(newContent); //add the text node to the newly created div. 

            // add the newly created element and its content into the DOM 
            //var currentDiv = document.getElementById('divMain');
            parent.appendChild(newDiv);
            servers.push(headers);
github jaruba / PowderPlayer / src / lib / dlna.js View on Github external
dlna.bestMatches.push(el[0]);
//						if (ij == 3) return true;
					}
				});
				
				if (dlna.bestMatches.length) {
					dlna.checkedPorts = [];
					dlna.tryKnown();
				} else player.setOpeningText("Error: Nothing Found");

			}
		},10000);
		$(".wcp-dlna-buttons").show(0);
	
		var Client = require('node-ssdp').Client
		  , client = new Client();
	
		client.on('response', function (headers, statusCode, rinfo) {
	//		console.log(headers);
			if (headers["LOCATION"]) {
				dlna.instance.clients.push(headers["LOCATION"]);
			}
			if (dlna.instance.clients.length == 1){
				if (headers["SERVER"]) dlna.instance.serverName = headers["SERVER"]; // remember the server name
//				console.log(headers["SERVER"]);
				dlna.findMyIp(); // remove this line for select device menu
			}
		});
		
	// uncomment this line for select device menu
	//	setTimeout(function() { checkClients(); },1000);
github philsawicki / Angular-SamsungTVRemote / api / services / discoveryService.js View on Github external
var search = function (SSDPSearchString, options) {
        options = options || {};
        options.SSDPTimeout = options.SSDPTimeout || 2*1000;

        var deferred = Q.defer();

        var SSDPClient = require('node-ssdp').Client,
            client = new SSDPClient(),
            responses = [];

        client.on('response', function (headers, statusCode, rinfo) {
            // Split on line breaks ("/r/n"):
            var headersFormatted = headers.split( String.fromCharCode(13, 10) );
            
            // Extract the headers:
            var headersParsed = {};
            for (var i = 0, nbHeaders = headersFormatted.length; i < nbHeaders; i++) {
                var item = headersFormatted[i];

                var firstColonIndex = item.indexOf(':');
                if (firstColonIndex > -1) {
                    var key = item.substring(0, firstColonIndex);
                    var value = item.substring(firstColonIndex + 1, item.length).trim();
github philsawicki / Angular-SamsungTVRemote / api / tv.js View on Github external
var details = function (req, res) {
        var SSDPClient = require('node-ssdp').Client,
            client = new SSDPClient(),
            SSDPResponses = [];

        client.on('response', function (headers, statusCode, rinfo) {
            // Split on line breaks ("/r/n"):
            var headersFormatted = headers.split( String.fromCharCode(13, 10) );
            
            // Extract the headers:
            var headersParsed = {};
            for (var i = 0, nbHeaders = headersFormatted.length; i < nbHeaders; i++) {
                var item = headersFormatted[i];

                var firstColonIndex = item.indexOf(':');
                if (firstColonIndex > -1) {
                    var key = item.substring(0, firstColonIndex);
                    var value = item.substring(firstColonIndex + 1, item.length).trim();
github glenmurphy / route / modules / sonos / sonos_experimental.js View on Github external
Sonos.prototype.scanforComponents = function() {
  if (!ssdp) return;
  var client = new ssdp.Client();
  var timeout;
  client.on('response', function (headers, statusCode, rinfo) {
    var host = rinfo.address;
    if (this.discoveredIps.indexOf(host) == -1) {
      this.discoveredIps.push(host);
      if (headers["ST"] != Sonos.PLAYER_UPNP_URN) return;     
      if (!headers["LOCATION"]) return;
      this.createComponent(host);
    }
  }.bind(this));

  // search periodcally
  function scanDevices() {
    if (this.debug) console.log("Scanning for sonos");
    client.search(Sonos.PLAYER_UPNP_URN);
    clearTimeout(timeout);
github davidcreager / smartthings-smartbulbs / smartserver.js View on Github external
console.log("smartserver:G_DeviceProperties: exception reading " + fName + " error=" + err);
			return null;
		}		
	}
	try {
		return  JSON.parse(data);
	} catch (exc) {
		console.log("smartserver:G_DeviceProperties: exception parsing json " + fName + " data=" + data + " exception=" + exc);
		return null;
	}
})();
console.log("smartserver:G_DeviceProperties=" + JSON.stringify(G_deviceProperties));
if (gTEST){
	console.log("Trying to get ssdps")
	var SSDPClient = require('node-ssdp').Client;
	var client = new SSDPClient({ allowWildcards:false});
	var searchString = 'urn:schemas-upnp-org:device*';
    client.on('response', function (response) {
		if (response.ST == searchString)
		console.log("response st=" + response.ST + " location=" + response.LOCATION +"\t usn=" + response.USN )
		});
	client.on('notify', function () {
	  console.log('Got a notification.')
	})
    // search for a service type
    //client.search('urn:schemas-upnp-org:device:SmartBridge*');
	//"urn:schemas-upnp-org:device:SmartBridge:1"
	//client.search("schemas-upnp-org:device:SmartBridge:1");
	//client.search('schemas-upnp-org:device:Smart*');
	//client.search('urn:schemas-upnp-org:device:RFXDevice:1')
	//urn:schemas-upnp-org:device
	client.search(searchString);
github netbeast / bigfoot / node / src / hunt.js View on Github external
return new Promise((resolve, reject) => {
    const timerRef = setTimeout(() => {
      if (typeof callback === 'function') callback(devices)
      resolve(devices)
    }, opts.duration || 2500)

    const client = new Client()
    client.search('ssdp:all')
    client.on('response', (headers, statusCode, rinfo) => {
      const searchTarget = headers.ST

      if (!(searchTarget.match(/^bigfoot:/) || {}).input) {
        return // Do nothing
      }

      // Enable to hunt only one device
      if (opts.id === headers.USN) {
        clearTimeout(timerRef)
        return resolve(parseResponse(headers, statusCode, rinfo))
      }

      devices = {
        ...devices,
github dhleong / wemore / lib / discover.js View on Github external
Discovery.prototype.close = function() {
    // hax?
    if (this.client) {
        this.client._stop();
    }

    // create a new one (apparently they're one-use only)
    this.client = new SsdpClient();
    this.client.on('response', this._onResponse.bind(this));
};
github bschlenk / node-roku-client / lib / discovery.js View on Github external
return new Promise((resolve, reject) => {
    const client = new nodeSSDPClient();

    // Open the flood gates
    const intervalId = setInterval(() => {
      client.search('ssdp:all');
    }, 1000);

    // Discovery timeout for roku device; default 10000ms
    const timeoutId = setTimeout(() => {
      clearInterval(intervalId);
      clearTimeout(timeoutId);

      return reject(new Error(`Could not find any Roku devices. Time spent: ${timeout / 1000} seconds`));
    }, timeout);

    client.on('response', headers => {
      if (self.debug) {

node-ssdp

A node.js SSDP client and server library.

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Popular node-ssdp functions