I've been using jdk8 websockets to develop my desktop java applications. Now that jdk9 is on my machine I started looking at websockets and I'm not at all sure I like what I see. Can someone familiar with this feature please explain the rationale for what is happening?
I'm concerned, at this initial stage, primarily by WebSocket.request(long). This "feature" seems to have at least two very negative impacts: 1) It appears to destroy the asynchronous nature of websockets; 2) It appears to place programmers in the impossible position of guessing how many messages the server side might send. 1) If everything has to stop while the client asks for more messages asynchronous communication is nullified. The jdk8 implementation is, therefore, much more functional. 2) It would appear the only logical use of WebSocket.request() would be to use a long value of Long.MAX_VALUE since there is no way to know how many messages may be received. And what if the programmer asks for 1 message and the next message has 3 parts. We're screwed. Additionally, the documentation specifically states that the WebSocket.Listener does not distinguish between partial and whole messages. The jdk8 implementation decoders/encoders accumulate messages and assemble them until the message is complete and then pass it to the Endpoint -- much more satisfactory arrangement. I cannot fathom the meaning or improvement of this new wrinkle. Thanks for any insight