The previous commits do not handle all of the edge cases of #583
appropriately. This is a short term solution that will work, but is not
as efficient as it could be. The whole refreshAccount function needs to
be reconsidered and replaced with a more sane way of handling atomic
updates to the user's account state.
Instead of emitting frames to each individual socket, group them into
socket.io rooms of people who can see hidden poll results and people who
can't, then just do 2 broadcasts.
If clients call it quickly in succession with large playlists, it can
cause node to get stuck stringifying socket.io frames and cause an out
of memory crash.
CyTube has been crashing recently due to things attempting to release
the reference after the channel was already closed (apparently the
uncaughtException handler isn't called for this?). This newer
implementation keeps track of what is ref'ing and unref'ing it, so it
can log an error if it detects a discrepancy.
Also changed the server to not delete the refCounter field from the
channel when it's unloaded, so that should reduce the number of errors
stemming from it being null/undefined.
If two people tried to play the same playlist item, before the playlist updated, it would delete instead of playing.
The same would also happen if the play button was double-clicked instead of single-clicked.
Also, the active item's play button functioned as a delete button.
Fully tested. Still removes the item (if it was added as temporary) when it finishes playing, or if the play button of a *different* item is clicked.