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

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

Introduction

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

Prototype

boolean isFinal();

Source Link

Usage

From source file:io.sqp.proxy.testhelpers.WebSocketFrameMatcher.java

License:Open Source License

@Override
public boolean matches(Object argument) {
    if (!(argument instanceof WebSocketFrame)) {
        return false;
    }//from   w w w.  ja v a 2s.c om
    WebSocketFrame frame = (WebSocketFrame) argument;
    if (_isFinal != frame.isFinal()) {
        return false;
    }

    if (_frameType.equals(FrameType.Binary) && !frame.isBinary()) {
        return false;
    } else if (_frameType.equals(FrameType.Text) && !frame.isText()) {
        return false;
    } else if (_frameType.equals(FrameType.Continuation) && !frame.isContinuation()) {
        return false;
    }

    byte[] frameContent = frame.binaryData().getBytes();
    return Arrays.equals(_expectedContent, frameContent);
}

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

License:Open Source License

public void handleFrame(WebSocketFrame frame) {
    ByteBuffer buf = new VertxByteBuffer(frame.binaryData());
    boolean isFinal = frame.isFinal();
    boolean isText = frame.isText();

    try {/*  w ww.jav  a 2  s.  c  o m*/
        if (isText || frame.isBinary()) {
            DataFormat format = isText ? DataFormat.Text : DataFormat.Binary;
            _msgReceiver.newMessage(format, buf, isFinal);
        } else if (frame.isContinuation()) {
            _msgReceiver.continueMessage(buf, isFinal);
        } else {
            throw new InvalidFrameException("Invalid frame type");
        }
    } catch (SqpException e) {
        _session.handleError(e);
    }
}