Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] websocket: simultaneous client request - possible or not ?

Hi everyone,
I'm working on an implementation of jetty websocket for a real-time game.
Every thing works fine, except one thing:
Let's say we work with the WebSocketChatServlet demo.
My method "onMessage" has a long process :

 public void onMessage(byte frame, String data)
        {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // Log.info(this+" onMessage: "+data);
            for (ChatWebSocket member : _members)
            {
                try
                {
                    member._outbound.sendMessage(frame,data);
                }
                catch(IOException e)
                {
                   // Log.warn(e);
                }
            }
        }

So when an user type very quickly: "a", "b", "c", the result will be :

*wait 2sec* => display "a"
*wait 2sec* => display "b"
*wait 2sec* => display "c"

What I need is a real use of socket (that means I don't have to wait the answer of the server before the client can send a new request).
In fact, the result I'm looking for is the following:

*wait 2sec* => display "a", display "b", display "c"

I've got this problem even without the Thread.sleep(2000): my client send a very important amount of data. Because of my delay with the server, I've got a queue of messages which are waiting to enter into the "onMessage" method.
I don't want this behaviour, it's not the "real" beahaviour of socket, don't you think ?

Is it possible using jetty websocket implementation ?

Regards

--
Quentin Ambard

Back to the top