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

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

Introduction

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

Prototype

static WebSocketFrame binaryFrame(Buffer data, boolean isFinal) 

Source Link

Document

Create a binary WebSocket 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);/*from  w w w .  ja v  a2  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;//from www  . ja va2  s .  co  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;
}

From source file:org.atmosphere.vertx.VertxWebSocket.java

License:Apache License

/**
 * {@inheritDoc}/*  w  w  w . j  av  a 2 s  . c o m*/
 */
@Override
public org.atmosphere.websocket.WebSocket write(byte[] data, int offset, int length) throws IOException {
    Buffer buf = Buffer.buffer().appendBytes(data, offset, length);

    webSocket.writeFrame(WebSocketFrame.binaryFrame(buf, true));
    return this;
}