Handle reception of partial data in WS client.
This commit is contained in:
parent
5b43aed0b4
commit
4259e5eccd
@ -43,13 +43,20 @@ public abstract class AbstractClientWS implements AbstractWS {
|
|||||||
Listener.super.onOpen(webSocket);
|
Listener.super.onOpen(webSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringBuilder partialData = new StringBuilder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletionStage<?> onText(WebSocket webSocket, CharSequence data, boolean last) {
|
public CompletionStage<?> onText(WebSocket webSocket, CharSequence data, boolean last) {
|
||||||
try {
|
partialData.append(data.toString());
|
||||||
AbstractClientWS.this.handleReceivedMessage(data.toString());
|
if (last) {
|
||||||
} catch (Exception e) {
|
try {
|
||||||
logError("Error handling reception of text.", e);
|
AbstractClientWS.this.handleReceivedMessage(partialData.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logError("Error handling reception of text.", e);
|
||||||
|
}
|
||||||
|
partialData = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Listener.super.onText(webSocket, data, last);
|
return Listener.super.onText(webSocket, data, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user