PretendYoureXyzzy
PretendYoureXyzzy copied to clipboard
User: use a stably-ordered queue for long-polling
If the AJAX request for LongPollServlet happens with enough of a delay, there may be two stateful messages in the queue -- I have observed two GAME_STATE_CHANGE messages enqueued simultaneously when the Card Czar does not long-poll while the other players progress the game through PLAYING to JUDGING. The JS code overwrites the state as it iterates the list, so the "last state wins". But PriorityQueue<E> explicitly does not guarantee any particular ordering among elements that compare "equal", causing the client to think the game is PLAYING.
Testing done
This avoids one flavor of error in a local client I'm developing, but to be honest, I'm still not finished debugging all of the other state-machine issues that it had.
yeah I don't think there's really much of a point to having a priority to the messages... it was a good idea but perhaps a bit premature and wasn't useful. heck the entire MessageType can probably be removed, since its point was to prioritize messages in this queue