Last active
November 24, 2015 16:59
-
-
Save mdobson/73b5a09fb99e944fc1d7 to your computer and use it in GitHub Desktop.
Scouting in Zetta.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sonos = require('sonos'); | |
var Scout = require('zetta-scout'); | |
var util = require('util'); | |
var SonosDriver = require('./sonos_driver'); | |
//We inherit from scout to get some Zetta functionality | |
var SonosScout = module.exports = function() { | |
Scout.call(this); | |
}; | |
util.inherits(SonosScout, Scout); | |
//Zetta calls this function to actually initialize a scout in the system | |
SonosScout.prototype.init = function(next) { | |
var self = this; | |
//We use the sonos specific library to search for devices. It should be able to speak the SOAP API with the device itself. | |
//We just want to make sure we can access that device in JavaScript. | |
sonos.search(function(device) { | |
//Callback is fired for every device found on the network. | |
//We call the discover method to tell Zetta a new Sonos driver came online. | |
//Any extra arguments passed to discover will get passed on to the constructor of SonosDriver | |
self.discover(SonosDriver, device); | |
//Move to the next scout. | |
next(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment