Skip to content

Commit

Permalink
Merge pull request #14 from lperrin/master
Browse files Browse the repository at this point in the history
Correctly iterating over devices in stopAll
  • Loading branch information
lperrin committed Jun 25, 2013
2 parents 0af1e28 + d58b1dc commit fb19b58
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/devices.js
Expand Up @@ -12,7 +12,7 @@ function Devices() {
this.source = null;
this.devices = {};
this.hasAirTunes = false;
};
}

util.inherits(Devices, events.EventEmitter);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
},
Expand Down

0 comments on commit fb19b58

Please sign in to comment.