diff --git a/lib/devices.js b/lib/devices.js index 96a9233..61d3c24 100644 --- a/lib/devices.js +++ b/lib/devices.js @@ -12,7 +12,7 @@ function Devices() { this.source = null; this.devices = {}; this.hasAirTunes = false; -}; +} util.inherits(Devices, events.EventEmitter); @@ -45,7 +45,7 @@ Devices.prototype.add = function(type, host, options) { new AirTunesDevice(host, options); var previousDev = this.devices[dev.key]; - + if(previousDev) { // if device is already in the pool, just report its existing status. previousDev.reportStatus(); @@ -109,8 +109,17 @@ Devices.prototype.setArtwork = function(key, art, contentType, callback) { }; Devices.prototype.stopAll = function(allCb) { + // conver to array to make async happy + var devices = []; + for(var i in this.devices) { + if(!this.devices.hasOwnProperty(i)) + continue; + + devices.push(this.devices[i]); + } + async.forEach( - this.devices, + devices, function(dev, cb) { dev.stop(cb); },