I want to stop streaming when the user clicks on a button which will set the post variable url as close.
Right now I have this, but it says engine is not defined. Which is true. But I am having a hard time solving this.
var url = req.body.torrent;
var indexOfMovie;
if(url=="close"){
res.sendfile('index.html');
engine.remove();
console.log("page closed");
}else{
var engine = torrentStream(url,{
path: 'tmp'
});
engine.on('ready', function() {
engine.remove();
var server = http.createServer(function(req, res) {
server.on("listening", function () { server.close(); });
if(url!="close"){
var file = engine.files[indexOfMovie];
res.setHeader('Content-Length', file.length);
file.createReadStream().pipe(res);
}
});
server.listen('2020');
});
}
This should probably be done by stopping the server and removing the engine. I tried that with server.close() if server is listening but that isn't doing much.
I want to stop streaming when the user clicks on a button which will set the post variable url as close. Right now I have this, but it says engine is not defined. Which is true. But I am having a hard time solving this.
This should probably be done by stopping the server and removing the engine. I tried that with server.close() if server is listening but that isn't doing much.