Skip to content

Commit

Permalink
Fix issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBobolz committed Oct 21, 2017
1 parent 65e3162 commit 643c249
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions harmony/harmony-server.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var HarmonyHubDiscover = require('harmonyhubjs-discover')
var harmonyClient = require('harmonyhubjs-client')
var events = require('events')

module.exports = function (RED) {
function HarmonyServerNode (n) {
RED.nodes.createNode(this, n)
var node = this

node.ip = n.ip
node.harmonyEventEmitter = new events.EventEmitter()
createClient(node)

this.on('close', function () {
Expand All @@ -29,6 +31,9 @@ module.exports = function (RED) {
}
harmonyClient(ip).then(function (harmony) {
node.harmony = harmony
harmony.on('stateDigest', function(digest) {
node.harmonyEventEmitter.emit('stateDigest', digest)
})
!(function keepAlive () {
harmony.request('getCurrentActivity').timeout(50000).then(function (response) {
setTimeout(keepAlive, 50000)
Expand Down
4 changes: 2 additions & 2 deletions harmony/harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ module.exports = function (RED) {

setTimeout(function () {
try {
node.server.harmony.on('stateDigest', function (digest) {
// console.log(JSON.stringify(digest));
node.server.harmonyEventEmitter.on('stateDigest', function (digest) {
// console.log(JSON.stringify(digest));
try {
node.send({
payload: {
Expand Down

0 comments on commit 643c249

Please sign in to comment.