From dbb802bb2836639346bb9034d658ecd13a005a6a Mon Sep 17 00:00:00 2001 From: Andy Janata Date: Mon, 30 Jan 2012 23:54:05 -0800 Subject: [PATCH] delay 5ms after noticing the user has a queued message before returning it in case other messages arrive immediately thereafter --- src/net/socialgamer/cah/LongPollServlet.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/net/socialgamer/cah/LongPollServlet.java b/src/net/socialgamer/cah/LongPollServlet.java index 097361e..0a07f4f 100644 --- a/src/net/socialgamer/cah/LongPollServlet.java +++ b/src/net/socialgamer/cah/LongPollServlet.java @@ -74,6 +74,12 @@ public class LongPollServlet extends CahServlet { } } if (user.hasQueuedMessages()) { + try { + // Delay for a short while in case there will be other messages queued to be delivered. + Thread.sleep(5); + } catch (final InterruptedException ie) { + // pass + } final Collection msgs = user.getNextQueuedMessages(MAX_MESSAGES_PER_POLL); // just in case... if (msgs.size() > 0) {