PretendYoureXyzzy icon indicating copy to clipboard operation
PretendYoureXyzzy copied to clipboard

User: use a stably-ordered queue for long-polling

Open mokomull opened this issue 4 years ago • 1 comments

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.

mokomull avatar Apr 10 '20 05:04 mokomull

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

ajanata avatar May 24 '20 01:05 ajanata