Package io.netty.channel

Examples of io.netty.channel.ChannelFuture.sync()


            textFrame.release();

            final String channelId = UUID.randomUUID().toString();
            final String register = JsonUtil.toJson(new RegisterMessageImpl(channelId));
            final ChannelFuture registerFuture = ch.writeAndFlush(new TextWebSocketFrame(register));
            registerFuture.sync();
            final TextWebSocketFrame registerFrame = handler.getTextFrame();
            final RegisterResponseImpl registerResponse = JsonUtil.fromJson(registerFrame.text(), RegisterResponseImpl.class);
            assertThat(registerResponse.getMessageType(), equalTo(MessageType.Type.REGISTER));
            assertThat(registerResponse.getChannelId(), equalTo(channelId));
View Full Code Here


            handler.handshakeFuture().sync();

            final String uaid = UUIDUtil.newUAID();
            final String json = JsonUtil.toJson(new HelloMessageImpl(uaid.toString()));
            final ChannelFuture future = ch.writeAndFlush(new TextWebSocketFrame(json));
            future.sync();
            final TextWebSocketFrame textFrame = handler.getTextFrame();
            final HelloResponse fromJson = JsonUtil.fromJson(textFrame.text(), HelloResponseImpl.class);
            assertThat(fromJson.getMessageType(), equalTo(MessageType.Type.HELLO));
            assertThat(fromJson.getUAID(), equalTo(uaid));
            textFrame.release();
View Full Code Here

            Thread.sleep(3000);
            final String channelId = UUID.randomUUID().toString();
            final String register = JsonUtil.toJson(new RegisterMessageImpl(channelId));
            final ChannelFuture registerFuture = ch.writeAndFlush(new TextWebSocketFrame(register));
            registerFuture.sync();
            ch.writeAndFlush(new CloseWebSocketFrame());
            ch.closeFuture().sync();
        } finally {
            group.shutdownGracefully();
        }
View Full Code Here

            List<Entry<String, String>> headers) throws Exception {
        // XXX /formpost
        // Start the connection attempt.
        ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
        // Wait until the connection attempt succeeds or fails.
        Channel channel = future.sync().channel();

        // Prepare the HTTP request.
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uriSimple.toASCIIString());

        // Use the PostBody encoder
View Full Code Here

            List<Entry<String, String>> headers, List<InterfaceHttpData> bodylist) throws Exception {
        // XXX /formpostmultipart
        // Start the connection attempt.
        ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
        // Wait until the connection attempt succeeds or fails.
        Channel channel = future.sync().channel();

        // Prepare the HTTP request.
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uriFile.toASCIIString());

        // Use the PostBody encoder
View Full Code Here

            ByteBuf buf = Unpooled.wrappedBuffer(data, i, length);
            if (useCompositeByteBuf) {
                buf = Unpooled.compositeBuffer().addComponent(buf).writerIndex(buf.writerIndex());
            }
            ChannelFuture future = cc.writeAndFlush(buf);
            future.sync();
            i += length;
        }

        while (ch.counter < data.length) {
            if (sh.exception.get() != null) {
View Full Code Here

        ServerBootstrap b = new ServerBootstrap();
        b.channel(OioServerSocketChannel.class);
        b.group(g);
        b.childHandler(new ChannelHandlerAdapter());
        ChannelFuture f1 = b.bind(0);
        f1.sync();

        ChannelFuture f2 = b.bind(0);
        f2.await();

        assertThat(f2.cause(), is(instanceOf(ChannelException.class)));
View Full Code Here

        ServerBootstrap sb = new ServerBootstrap();
        sb.channel(OioServerSocketChannel.class);
        sb.group(g);
        sb.childHandler(new ChannelHandlerAdapter());
        ChannelFuture f1 = sb.bind(0);
        f1.sync();

        Bootstrap cb = new Bootstrap();
        cb.channel(OioSocketChannel.class);
        cb.group(g);
        cb.handler(new ChannelHandlerAdapter());
View Full Code Here

        ServerBootstrap sb = new ServerBootstrap();
        sb.channel(OioServerSocketChannel.class);
        sb.group(g);
        sb.childHandler(new ChannelHandlerAdapter());
        ChannelFuture f1 = sb.bind(0);
        f1.sync();

        Socket s = new Socket(NetUtil.LOCALHOST, ((InetSocketAddress) f1.channel().localAddress()).getPort());
        assertThat(s.getInputStream().read(), is(-1));
        s.close();
View Full Code Here

            List<Entry<String, String>> headers) throws Exception {
        // XXX /formpost
        // Start the connection attempt.
        ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
        // Wait until the connection attempt succeeds or fails.
        Channel channel = future.sync().channel();

        // Prepare the HTTP request.
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uriSimple.toASCIIString());

        // Use the PostBody encoder
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.