diff --git a/README.md b/README.md index 7ed09f0..692e49a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ -Canopy - 0.2.1-INDEV +Canopy - 0.2.1-INDEV (verbose queue) ====== +--- + +This branch exists to seperate the extra shit I added to the queue for bug-hunting so it wouldn't make a mess of the main development branch :P + +--- + Canopy - /ˈkæ.nə.pi/: - The upper layer of foliage and branches of a forest, containing the majority of animal life. diff --git a/src/app/channel/media/queue.js b/src/app/channel/media/queue.js index fa489ae..7e342dd 100644 --- a/src/app/channel/media/queue.js +++ b/src/app/channel/media/queue.js @@ -60,8 +60,22 @@ module.exports = class{ socket.on("clear", (data) => {this.deleteRange(socket, data)}); socket.on("move", (data) => {this.moveMedia(socket, data)}); socket.on("lock", () => {this.toggleLock(socket)}); + + + socket.on("chanDump", () => {this.chanDump(socket)}); } + chanDump(socket){ + socket.emit('chanDump', + { + nowPlaying: this.nowPlaying, + schedule: Array.from(this.schedule), + //timer: this.nextTimer + } + ) + } + + //--- USER FACING QUEUEING FUNCTIONS --- async queueURL(socket, data){ //Get the current channel from the database @@ -149,6 +163,7 @@ module.exports = class{ //End the media this.end(); + console.log(`Media set to end due at the request of ${socket.user}`); } } @@ -298,6 +313,9 @@ module.exports = class{ clearTimeout(this.nextTimer); //Set the next timer this.nextTimer = setTimeout(()=>{this.start(nextItem, nextItem.startTimeStamp, volatile)}, startsIn); + console.log(`next item '${nextItem.title}' timer set to start in ${startsIn} seconds`); + }else{ + console.log('next timer is unset'); } } @@ -461,6 +479,7 @@ module.exports = class{ if(this.nowPlaying != null && this.nowPlaying.uuid == uuid){ //End playback this.end(false, true); + console.log("Media ended due to removal of media"); //otherwise }else{ try{ @@ -661,6 +680,7 @@ module.exports = class{ //Silently end the media in RAM so the database isn't stepping on itself up ahead //Alternatively we could've used await, but then we'd be doubling up on DB transactions :P this.end(true, true, true); + console.log("Media ended due to start of new media"); } //reset current timestamp @@ -732,6 +752,7 @@ module.exports = class{ //Call the end function once the video is over this.syncTimer = setTimeout(this.end.bind(this), leftover); + console.log(`Media set to end by sync function in ${leftover} milliseconds`); } } @@ -768,13 +789,17 @@ module.exports = class{ //FUCK throw new Error(`Unable to find channel document ${this.channel.name} while ending queue item!`); } - - //If we haven't changed 'nowPlaying' in the play list + + //If we haven't changed 'nowPlaying' in the DB if(chanDB.media.nowPlaying.uuid == wasPlaying.uuid){ //Take it out await chanDB.media.nowPlaying.deleteOne(); } + //NOTE: Keep an eye on this + //It seems this was part of my original design (don't remember was high) + //Though it is weird we keep it in both this.schedule and this.nowPlaying at the same time... + //More testing will have to be done... //Take it out of the active schedule this.schedule.delete(wasPlaying.startTime);