use of io.vertx.core.http.WebSocketFrame in project vert.x by eclipse.
the class WebSocketImplBase method writePartialMessage.
/**
* Splits the provided buffer into multiple frames (which do not exceed the maximum web socket frame size)
* and writes them in order to the socket.
*/
private void writePartialMessage(FrameType frameType, Buffer data, int offset) {
int end = offset + maxWebSocketFrameSize;
boolean isFinal;
if (end >= data.length()) {
end = data.length();
isFinal = true;
} else {
isFinal = false;
}
Buffer slice = data.slice(offset, end);
WebSocketFrame frame;
if (offset == 0 || !supportsContinuation) {
frame = new WebSocketFrameImpl(frameType, slice.getByteBuf(), isFinal);
} else {
frame = WebSocketFrame.continuationFrame(slice, isFinal);
}
writeFrame(frame);
int newOffset = offset + maxWebSocketFrameSize;
if (!isFinal) {
writePartialMessage(frameType, data, newOffset);
}
}
use of io.vertx.core.http.WebSocketFrame in project vert.x by eclipse.
the class WebSocketImplBase method writeBinaryFrameInternal.
private void writeBinaryFrameInternal(Buffer data) {
ByteBuf buf = data.getByteBuf();
WebSocketFrame frame = new WebSocketFrameImpl(FrameType.BINARY, buf);
writeFrame(frame);
}
use of io.vertx.core.http.WebSocketFrame in project vert.x by eclipse.
the class WebSocketImplBase method writeTextFrameInternal.
private void writeTextFrameInternal(String str) {
WebSocketFrame frame = new WebSocketFrameImpl(str);
writeFrame(frame);
}
Aggregations