cast-scanner v1.0.0
cast-scanner
Scan your local network for all Chromecast devices.
Originally based on xat/chromecast-scanner.
Installation
npm install dcpesses/cast-scanner
Usage
var scanner = require('cast-scanner');Results can be obtained through either a callback and/or an event.
Simple Callback
scanner(function(data) {
console.log('data:', data);
});Event Listener
scanner.on('results', function(data) {
console.log('data:', data);
});More usage examples can be found in the examples folder.
API
scanner([options], [callback]);options: Object (optional)ttlNumber (optional) - Lifespan (in milliseconds) to wait for responses from all devices. Default:5000mdnsObject (optional) - Config to pass to multicast-dns. Default:{}debug: Verbose logging to console. Default:falsecallbackFunction (optional)
Returns CastScanner instance
Creates a CastScanner instance using any provided options and/or a callback function.
Events
Event: init
Returns:
eventEventtypeStringtimestampNumber - Unix timestamp of when initialization occurred.
Emitted after the module is initialized.
Event: update
Returns:
eventEventtypeStringdeviceObject - Chromecast device objectnameString - Local domain namedisplayNameString - Name displayed to usersshortNameStringhostStringipString - IP address of devicerecordsObject - 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:
eventEventtypeStringtimestampNumber - Unix timestamp of when initialization occurred.durationNumber - Approximate ttl used to wait for device responses.
Emitted when the connection is closed
Event: results
Returns:
eventEventtypeStringdevicesArray - 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.
Methods
scanner.close()Stops waiting for device responses and clears the ttl timeout.
License
MIT
7 years ago