Package org.asynchttpclient.providers.netty.ws

Examples of org.asynchttpclient.providers.netty.ws.NettyWebSocket


            future.done();

        } else if (e instanceof WebSocketFrame) {

            final WebSocketFrame frame = (WebSocketFrame) e;
            NettyWebSocket webSocket = NettyWebSocket.class.cast(handler.onCompleted());
            invokeOnSucces(channel, handler);

            if (webSocket != null) {
                if (frame instanceof CloseWebSocketFrame) {
                    Channels.setDiscard(channel);
                    CloseWebSocketFrame closeFrame = CloseWebSocketFrame.class.cast(frame);
                    webSocket.onClose(closeFrame.statusCode(), closeFrame.reasonText());
                } else {
                    ByteBuf buf = frame.content();
                    if (buf != null && buf.readableBytes() > 0) {
                        try {
                            NettyResponseBodyPart part = nettyConfig.getBodyPartFactory().newResponseBodyPart(buf, frame.isFinalFragment());
                            handler.onBodyPartReceived(part);

                            if (frame instanceof BinaryWebSocketFrame) {
                                webSocket.onBinaryFragment(part);
                            } else if (frame instanceof TextWebSocketFrame) {
                                webSocket.onTextFragment(part);
                            } else if (frame instanceof PingWebSocketFrame) {
                                webSocket.onPing(part);
                            } else if (frame instanceof PongWebSocketFrame) {
                                webSocket.onPong(part);
                            }
                        } finally {
                            buf.release();
                        }
                    }
View Full Code Here


        logger.warn("onError {}", e);

        try {
            WebSocketUpgradeHandler h = WebSocketUpgradeHandler.class.cast(future);

            NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted());
            if (webSocket != null) {
                webSocket.onError(e.getCause());
                webSocket.close();
            }
        } catch (Throwable t) {
            logger.error("onError", t);
        }
    }
View Full Code Here

    public void onClose(NettyResponseFuture<?> future) {
        logger.trace("onClose {}");

        try {
            WebSocketUpgradeHandler h = WebSocketUpgradeHandler.class.cast(future);
            NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted());

            logger.trace("Connection was closed abnormally (that is, with no close frame being sent).");
            if (webSocket != null)
                webSocket.close(1006, "Connection was closed abnormally (that is, with no close frame being sent).");
        } catch (Throwable t) {
            logger.error("onError", t);
        }
    }
View Full Code Here

    public class DefaultNettyWebSocketFactory implements NettyWebSocketFactory {

        @Override
        public NettyWebSocket newNettyWebSocket(Channel channel, NettyAsyncHttpProviderConfig nettyConfig) {
            return new NettyWebSocket(channel, nettyConfig);
        }
View Full Code Here

TOP

Related Classes of org.asynchttpclient.providers.netty.ws.NettyWebSocket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.