Originally based on xat/chromecast-scanner.
npm install dcpesses/cast-scanner
var scanner = require('cast-scanner');
Results can be obtained through either a callback and/or an event.
scanner(function(data) {
console.log('data:', data);
});
scanner.on('results', function(data) {
console.log('data:', data);
});
More usage examples can be found in the examples
folder.
scanner([options], [callback]);
options
: Object (optional)ttl
Number (optional) - Lifespan (in milliseconds) to wait for responses from all devices. Default:5000
mdns
Object (optional) - Config to pass to multicast-dns. Default:{}
debug
: Verbose logging to console. Default:false
callback
Function (optional)
Returns CastScanner instance
Creates a CastScanner instance using any provided options and/or a callback function.
Event: init
Returns:
event
Eventtype
Stringtimestamp
Number - Unix timestamp of when initialization occurred.
Emitted after the module is initialized.
Event: update
Returns:
event
Eventtype
Stringdevice
Object - Chromecast device objectname
String - Local domain namedisplayName
String - Name displayed to usersshortName
Stringhost
Stringip
String - IP address of devicerecords
Object - DNS records received from device like (e.g. "A", "SRV", "TXT", etc)
Emitted when a response is received from a valid casting device.
Event: close
Returns:
event
Eventtype
Stringtimestamp
Number - Unix timestamp of when initialization occurred.duration
Number - Approximate ttl used to wait for device responses.
Emitted when the connection is closed.
Event: results
Returns:
event
Eventtype
Stringdevices
Array - All valid Chromecast devices found.
Emitted once the scanner is no longer listening for any more devices and all of the responses have been processed.
Each object in the devices
array uses the same format as the details
object emitted from an 'update' event.
scanner.close()
Removes the response listener and clears the ttl timeout. Useful if you no longer want to listen for any additional responses.
MIT