TooTallNate/Java-WebSocket — Issue #59: Draft_75 long messages (+suggested patch)
Author: lassic
Created: 2012-01-17 17:54:24+00:00
State: open

Hi,
I'm using this library on Android to communicate with an (old?) Draft_75 server.
I found that long messages from the server were not assembled correctly on the client side.
I'm not a big expert on web sockets, so I'm not even sure Draft_75 is supposed to handle this on the client or how.
Could be a crude hack, but what I ended up doing to get it working was:

// Changes to Draft_75 class

1. add a boolean field:
private boolean appending = false;

2. inside if (readingState) { ... }
curframe.setOptcode ( Opcode.CONTINIOUS ); // instead of TEXT
this.appending = true;

3. when closing the read on END_OF_FRAME:
curframe.setOptcode ( this.appending ? Opcode.CONTINIOUS : Opcode.TEXT );
this.appending = false;

This makes WebSocket enter the Opcode.CONTINIOUS state when reading such frames,
and when the fin is marked on the last frame part, the message is emitted.

Sorry if this is way off or something, hopefully it will help somehow.