users@websocket-spec.java.net

[jsr356-users] RemoteEndpoint.getSendWriter() and getSendStream() sugguestions

From: Norman Maurer <nmaurer_at_redhat.com>
Date: Fri, 8 Feb 2013 09:28:50 +0100

Hi all,

while working on my implementation of RemoteEndpoint I encountered a few issues. Well not really issues but a few things I would like to start a discussion about..

Most important I wonder why RemoteEndpoint.getSendWriter() and getSendStream() don't take a payload size as argument. The problem at the moment is that the whole message needs to be buffered till the close() method was called. This is because the length of the message (websocket frame) is encoded in the "header" of the message (at least for all the versions > 00) . So without knowing the size up-front it is not possible to start the transfer as it needs to get calculated from the whole message. I think this is very inefficient and can result in a lot of memory usage on the implementation, as the user may send a very big message. If the method signature would be changed to take the payload size it would be possible to directly start the transfer of the message and send data in "chunks" over the wire.

Feedback welcome…

Cheers,
Norman

---
Norman Maurer
nmaurer_at_redhat.com
JBoss, by Red Hat