Example usage for io.vertx.core.http WebSocketFrame continuationFrame

List of usage examples for io.vertx.core.http WebSocketFrame continuationFrame

Introduction

In this page you can find the example usage for io.vertx.core.http WebSocketFrame continuationFrame.

Prototype

static WebSocketFrame continuationFrame(Buffer data, boolean isFinal) 

Source Link

Document

Create a continuation frame

Usage

From source file:examples.HTTPExamples.java

License:Open Source License

public void example56(WebSocket websocket, Buffer buffer1, Buffer buffer2, Buffer buffer3) {

    WebSocketFrame frame1 = WebSocketFrame.binaryFrame(buffer1, false);
    websocket.writeFrame(frame1);/*  w w w.  ja  v a  2  s.c o m*/

    WebSocketFrame frame2 = WebSocketFrame.continuationFrame(buffer2, false);
    websocket.writeFrame(frame2);

    // Write the final frame
    WebSocketFrame frame3 = WebSocketFrame.continuationFrame(buffer2, true);
    websocket.writeFrame(frame3);

}

From source file:io.sqp.proxy.vertx.WebsocketWriteStream.java

License:Open Source License

private void flushSlice(Buffer buffer, int from, int length, boolean isFinal) {
    // a slice is just a view on the same buffer: no need to copy something
    Buffer outBuf = buffer.slice(from, from + length);

    WebSocketFrame frame;//  ww  w.  ja  v a  2 s.c o m
    if (!_firstFrameWritten) {
        if (_format == DataFormat.Binary) {
            frame = WebSocketFrame.binaryFrame(outBuf, isFinal);
        } else {
            frame = WebSocketFrame.textFrame(outBuf.toString("UTF-8"), isFinal);
        }
    } else {
        frame = WebSocketFrame.continuationFrame(outBuf, isFinal);
    }
    _socket.writeFrame(frame);
    _firstFrameWritten = true;
}