Made it so the backend cancels streams that are rerequested by the client

This commit is contained in:
subnub
2020-05-11 13:28:09 -04:00
parent d44954f387
commit c0fff08631
5 changed files with 19 additions and 22 deletions
+1 -1
View File
@@ -372,7 +372,7 @@ class FileController {
//tempStorage[req.params.uuid] = uuid.v4();
console.log("stream request", tempStorage)
console.log("stream request");
// req.on("close", () => {
// console.log("req closed stream");
@@ -256,22 +256,13 @@ class FileSystemService implements ChunkInterface {
readStream.pipe(decipher);
req.on("close", () => {
// console.log("req closed");
readStream.destroy();
})
const tempUUID = req.params.uuid;
// req.on("close", () => {
// // console.log("Destroying read stream");
// // readStream.destroy();
// // console.log("Read Stream Destoryed");
// })
// req.on("error", () => {
// console.log("req error");
// })
// req.on("pause", () => {
// console.log("req pause")
// })
await awaitStreamVideo(start, end, differenceStart, decipher, res, tempUUID, allStreamsToErrorCatch);
}
@@ -279,6 +279,12 @@ class MongoService implements ChunkInterface {
readStream.pipe(decipher);
req.on("close", () => {
// console.log("req closed");
readStream.destroy();
})
const tempUUID = req.params.uuid;
await awaitStreamVideo(start, end, differenceStart, decipher, res, tempUUID, allStreamsToErrorCatch);
+4 -4
View File
@@ -214,15 +214,15 @@ class S3Service implements ChunkInterface {
// })
req.on("close", () => {
console.log("req closed");
// console.log("req closed");
s3ReadStream.destroy();
})
//req.on("")
req.on("end", () => {
console.log("req end");
})
// req.on("end", () => {
// console.log("req end");
// })
await awaitStreamVideo(start, end, differenceStart, decipher, res, tempUUID, allStreamsToErrorCatch);
}
@@ -21,18 +21,18 @@ const awaitStreamVideo = (start: number, end:number, differenceStart: number,
//console.log(tempStorage[tempUUID] !== currentUUID, tempStorage[tempUUID])
if (tempStorage[tempUUID] !== currentUUID) {
console.log("New Stream Requested, Desroying old stream");
//console.log("New Stream Requested, Desroying old stream");
streamsToErrorCatch.forEach((stream) => {
stream.destroy();
})
console.log("Old Stream Desroyed");
//console.log("Old Stream Desroyed");
resolve();
//delete tempStorage[tempUUID];
}
console.log("stream passed", currentUUID);
//console.log("stream passed", currentUUID);
// if (tempStorage[tempUUID] !== undefined && tempStorage[tempUUID] !== currentUUID) {