Skip to content

Commit

Permalink
Close down RTL-SDR device properly on browser exit
Browse files Browse the repository at this point in the history
This doesn't seem to work on browser tab close though
  • Loading branch information
watson committed Dec 10, 2017
1 parent 2723431 commit 8e29080
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ function startServer () {
const url = 'http:https://localhost:' + port
if (argv.openBrowser) {
console.log('Opening %s in your favorite browser...', url)
opn(url)
opn(url).then(function () {
console.log('Closing down RTL-SDR device...')
rtlsdr.cancel_async(dev)
rtlsdr.close(dev)
process.exit()
})
} else {
console.log('Server running at: %s', url)
}
Expand Down

0 comments on commit 8e29080

Please sign in to comment.