jetgrizzly/jetgrizzly — pull request #95 by jgladch (2014-10-24 18:59:16+00:00)
Title: (fix) Fix Broken Server Logic

This PR implements a server queue that works for the base cases in my testing. I'm not convinced it is working in all cases and I'm also not sure that we won't see the same type of issues with this server as with the client queue logic because I'm not sure that my throttling strategy is working.

Basically, every client is still updating firebase by setting youTube/isPlaying to false every time it finishes. The server hears each of those changes and attempts to throttle how many times it changes the next song by setting a flag to true ('beenCalled' on line 27 of index.js) when the first change has been triggered.

This could also potentially be solved on the client side, by having the player check if 'isPlaying' had been already set to false before trying make it false again.

This code is not pretty, I'm not proud of it, but it appears to work correctly. It needs to be tested with multiple people using the room simultaneously and adding videos. It is ugly, but heavily commented. I believe you should be able to see what I am trying to do.