Search in sources :

Example 11 with CloseWebSocketFrame

use of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame in project async-http-client by AsyncHttpClient.

the class NettyWebSocket method handleFrame.

public void handleFrame(WebSocketFrame frame) {
    if (frame instanceof TextWebSocketFrame) {
        onTextFrame((TextWebSocketFrame) frame);
    } else if (frame instanceof BinaryWebSocketFrame) {
        onBinaryFrame((BinaryWebSocketFrame) frame);
    } else if (frame instanceof CloseWebSocketFrame) {
        Channels.setDiscard(channel);
        CloseWebSocketFrame closeFrame = (CloseWebSocketFrame) frame;
        onClose(closeFrame.statusCode(), closeFrame.reasonText());
        Channels.silentlyCloseChannel(channel);
    } else if (frame instanceof PingWebSocketFrame) {
        onPing((PingWebSocketFrame) frame);
    } else if (frame instanceof PongWebSocketFrame) {
        onPong((PongWebSocketFrame) frame);
    }
}
Also used : CloseWebSocketFrame(io.netty.handler.codec.http.websocketx.CloseWebSocketFrame) PongWebSocketFrame(io.netty.handler.codec.http.websocketx.PongWebSocketFrame) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) BinaryWebSocketFrame(io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame) PingWebSocketFrame(io.netty.handler.codec.http.websocketx.PingWebSocketFrame)

Aggregations

CloseWebSocketFrame (io.netty.handler.codec.http.websocketx.CloseWebSocketFrame)11 TextWebSocketFrame (io.netty.handler.codec.http.websocketx.TextWebSocketFrame)4 WebSocketFrame (io.netty.handler.codec.http.websocketx.WebSocketFrame)4 URI (java.net.URI)4 FrameChecker (io.undertow.websockets.utils.FrameChecker)3 WebSocketTestClient (io.undertow.websockets.utils.WebSocketTestClient)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Test (org.junit.Test)3 FutureResult (org.xnio.FutureResult)3 Channel (io.netty.channel.Channel)2 BinaryWebSocketFrame (io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame)2 PingWebSocketFrame (io.netty.handler.codec.http.websocketx.PingWebSocketFrame)2 PongWebSocketFrame (io.netty.handler.codec.http.websocketx.PongWebSocketFrame)2 ServerWebSocketContainer (io.undertow.websockets.jsr.ServerWebSocketContainer)2 UndertowSession (io.undertow.websockets.jsr.UndertowSession)2 AnnotatedClientEndpoint (io.undertow.websockets.jsr.test.annotated.AnnotatedClientEndpoint)2 ByteBuffer (java.nio.ByteBuffer)2 ExecutionException (java.util.concurrent.ExecutionException)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2