Skip to content

Commit

Permalink
Non-fixed port for discovery. (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
docbobo committed Jan 2, 2018
1 parent 2d42ffa commit d4d4ee0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
27 changes: 19 additions & 8 deletions app.js
Expand Up @@ -7,7 +7,8 @@ var debug = require('debug')('roon-extension-harmony'),
RoonApiSettings = require('node-roon-api-settings'),
RoonApiSourceControl = require('node-roon-api-source-control'),
Discover = require('harmonyhubjs-discover'),
Harmony = require('harmonyhubjs-client');
Harmony = require('harmonyhubjs-client'),
PortFinder = require('portfinder');

var util = require('util');
var EventEmitter = require('events').EventEmitter;
Expand Down Expand Up @@ -67,22 +68,32 @@ function HarmonyDiscovery() {

self.hubs = [];

self._discover = new Discover(61991);
self._discover.on('update', function (hubs) {
debug('received update event from harmonyhubjs-discover. there are \'%d\' hubs: %O', hubs.length, hubs);
PortFinder.getPortPromise()
.then((port) => {
debug("Harmony Discovery - listening on port \'%d\'", port);

self.hubs = hubs.map((entry) => { return new HarmonyHub(entry.friendlyName, entry.ip); });
});
self._discover = new Discover(port);
self._discover.on('update', function (hubs) {
debug("received update event from harmonyhubjs-discover. there are \'%d\' hubs: %O", hubs.length, hubs);

self.hubs = hubs.map((entry) => { return new HarmonyHub(entry.friendlyName, entry.ip); });
});

self._discover.start();
self._discover.start();
})
.catch((error) => {
debug("HarmonyDiscovery - Failed to find available port.", activity.id);

console.log(error);
});
}

var harmonyDiscovery = new HarmonyDiscovery();

var roon = new RoonApi({
extension_id: 'org.pruessmann.roon.logitech.harmony',
display_name: 'Logitech Harmony',
display_version: '0.0.5',
display_version: '0.0.6',
publisher: 'Doc Bobo',
email: 'boris@pruessmann.org',
website: 'https://github.com/docbobo/roon-extension-harmony',
Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,15 +1,16 @@
{
"name": "roon-extension-harmony",
"version": "0.0.5",
"version": "0.0.6",
"description": "Roon Extension to let Roon control Logitech Harmony hubs",
"main": "app.js",
"author": "Doc Bobo <boris@pruessmann.org> (https://blog.pruessmann.org/)",
"license": "Apache-2.0",
"private": true,
"dependencies": {
"debug": "^3.1.0",
"portfinder": "^1.0.0",
"harmonyhubjs-client": "^1.1.0",
"harmonyhubjs-discover": "^1.0.0",
"harmonyhubjs-discover": "^1.1.0",
"node-roon-api": "github:roonlabs/node-roon-api#caca92e99fd6becfc97761d32333cf4cd914b438",
"node-roon-api-settings": "github:roonlabs/node-roon-api-settings#67cd8ca156c5bcd01ea63833ceaaec6d6a79654d",
"node-roon-api-source-control": "github:roonlabs/node-roon-api-source-control#31ba0da65baab2261df35b0c787516e6064532d6",
Expand Down

0 comments on commit d4d4ee0

Please sign in to comment.