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

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

Introduction

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

Prototype

static WebSocketFrame textFrame(String str, boolean isFinal) 

Source Link

Document

Create a text WebSocket frame.

Usage

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 w w  w  .  ja  va  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;
}

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

License:Apache License

/**
 * {@inheritDoc}/* www.ja v  a  2  s  .  c om*/
 */
@Override
public org.atmosphere.websocket.WebSocket write(String data) throws IOException {
    logger.trace("WebSocket.write()");

    webSocket.writeFrame(WebSocketFrame.textFrame(data, true));
    lastWrite = System.currentTimeMillis();
    return this;
}

From source file:org.springframework.integration.vertx.WebSocketConnection.java

License:Apache License

@Override
public void send(Message<?> message) throws Exception {

    Optional<Object> vertxBody = VertxHelper.getVertxBody(message);
    if (vertxBody.isPresent()) {
        this.socket.writeFrame(WebSocketFrame.textFrame((String) vertxBody.get(), true));
    }/*  w  w w  . jav  a2 s  .  c  o m*/

}