Search in sources :

Example 6 with WebSocketException

use of org.eclipse.jetty.websocket.api.WebSocketException in project jetty.project by eclipse.

the class Parser method parse.

public void parse(ByteBuffer buffer) throws WebSocketException {
    if (buffer.remaining() <= 0) {
        return;
    }
    try {
        // parse through all the frames in the buffer
        while (parseFrame(buffer)) {
            if (LOG.isDebugEnabled())
                LOG.debug("{} Parsed Frame: {}", policy.getBehavior(), frame);
            notifyFrame(frame);
            if (frame.isDataFrame()) {
                priorDataFrame = !frame.isFin();
            }
            reset();
        }
    } catch (WebSocketException e) {
        // consume remaining
        buffer.position(buffer.limit());
        reset();
        // let session know
        notifyWebSocketException(e);
        // need to throw for proper close behavior in connection
        throw e;
    } catch (Throwable t) {
        // consume remaining
        buffer.position(buffer.limit());
        reset();
        // let session know
        WebSocketException e = new WebSocketException(t);
        notifyWebSocketException(e);
        // need to throw for proper close behavior in connection
        throw e;
    }
}
Also used : WebSocketException(org.eclipse.jetty.websocket.api.WebSocketException)

Aggregations

WebSocketException (org.eclipse.jetty.websocket.api.WebSocketException)6 DecodeException (javax.websocket.DecodeException)2 Decoder (javax.websocket.Decoder)2 DecoderFactory (org.eclipse.jetty.websocket.jsr356.DecoderFactory)2 AnnotatedTextSocket (examples.AnnotatedTextSocket)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Binary (javax.websocket.Decoder.Binary)1 Extension (org.eclipse.jetty.websocket.api.extensions.Extension)1 CloseInfo (org.eclipse.jetty.websocket.common.CloseInfo)1 CloseableLocalWebSocketSession (org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession)1 LocalWebSocketSession (org.eclipse.jetty.websocket.common.io.LocalWebSocketSession)1 Test (org.junit.Test)1