Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #50 from vincentbernat/fix/chromecast-recovery
Browse files Browse the repository at this point in the history
chromecast: on error, check status
  • Loading branch information
vincentbernat committed Apr 29, 2017
2 parents 34f8b92 + 772dcc3 commit 48d8964
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/chromecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ function update(device, status) {
}

function checkStatus(device) {
logger.debug('checking status of Chromecast device', device);
device.status(function(err, status) {
if (err) {
logger.exception('unable to get status from Chromecast device', err);
// Try to reconnect...
device.stop();
device.connect();
return;
}
update(device, status);
Expand Down Expand Up @@ -143,8 +147,12 @@ function chromecast() {
update(device, status);
}
})
.on('reconnect_failed', function() {
logger.warn('cannot reconnect to Chromecast device', device);
})
.on('error', function(err) {
logger.exception('An error occurred with some Chromecast device', err, device);
checkStatus(device);
});

// If there is a change to a group or if a display changes of
Expand Down

0 comments on commit 48d8964

Please sign in to comment.