users@websocket-spec.java.net

[jsr356-users] [jsr356-experts] Re: Streaming API: was For Review: v002 API and example code

From: Greg Wilkins <gregw_at_intalio.com>
Date: Wed, 4 Jul 2012 09:56:10 +0200

On 30 June 2012 01:03, Danny Coward <danny.coward_at_oracle.com> wrote:

> WebSocketListener -> public void onMessageAsInputStream(InputStream is)
>

How about having that for blocking API , but for async have the option of

  WebSocketAsyncListener - > public void
onMessageAsAsyncByteChannel(AsyncByteChannel channel)

the write methods on the channel would throw IllegalStateException

I'm not the biggest fan of the NIO.2 read API because it requires you to
preallocate the buffers when you call the read - but in this case it is not
so bad as you only allocate the buffers when the first frame of the message
arrives, so you are not holding the buffers forever.

I think better APIs can be designed, but we should at least consider going
with the JVMs standard API

cheers





-- 
Greg Wilkins <gregw_at_intalio.com>
www.webtide.com
Developer advice, services and support
from the Jetty & CometD experts.