Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.DefaultChannelFuture


    }
    final SslHandler ssl = future.getChannel().getPipeline()
                .get(SslHandler.class);
    if (null != ssl)
    {
      handler.channelFuture = new DefaultChannelFuture(
              future.getChannel(), false);
      future.addListener(new ChannelFutureListener()
      {
        public void operationComplete(ChannelFuture future)
                throws Exception
View Full Code Here


       
        Channel channel = createMock(Channel.class);
        expect(channel.isOpen()).andReturn(true).anyTimes();
        ChannelEvent event = createMock(ChannelEvent.class);
        expect(event.getChannel()).andReturn(channel).anyTimes();
        expect(event.getFuture()).andReturn(new DefaultChannelFuture(channel,false)).anyTimes();
        replay(channel, event);
       
        final CountDownLatch latch = new CountDownLatch(1);
       
        OrderedMemoryAwareThreadPoolExecutor executor = new OrderedMemoryAwareThreadPoolExecutor(10, 0L, 0L);
View Full Code Here

    }
   
    @Test
    public void testReleaseExternalResourceViaDownstreamEvent() throws Exception {
        Channel channel = createMock(Channel.class);
        expect(channel.getCloseFuture()).andReturn(new DefaultChannelFuture(channel, false));
        ChannelEvent event = createMock(ChannelEvent.class);
        expect(event.getChannel()).andReturn(channel).anyTimes();
        expect(event.getFuture()).andReturn(new DefaultChannelFuture(channel,false)).anyTimes();
       

        replay(channel, event);

        final CountDownLatch latch = new CountDownLatch(1);
View Full Code Here

                request.addHeader(e.getKey(), e.getValue());
            }
        }

        ChannelFuture future = channel.write(request);
        final ChannelFuture handshakeFuture = new DefaultChannelFuture(channel, false);

        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) {
                ChannelPipeline p = future.getChannel().getPipeline();
                p.replace(HttpRequestEncoder.class, "ws-encoder", new WebSocket13FrameEncoder(true));

                if (future.isSuccess()) {
                    handshakeFuture.setSuccess();
                } else {
                    handshakeFuture.setFailure(future.getCause());
                }
            }
        });

        return handshakeFuture;
View Full Code Here

        final String name = cluster.getMyNodeInfo().getName();
        LOG.debug("Writing node name, {}, to channel.", name);
        final byte[] array = name.getBytes(Charsets.UTF_8);
        final ChannelBuffer message = ChannelBuffers.wrappedBuffer(array);
        ctx.sendDownstream(new DownstreamMessageEvent(channel, new DefaultChannelFuture(channel, false), message, null));

        super.channelConnected(ctx, e);

        ctx.getPipeline().remove(this);
    }
View Full Code Here

        if (parentHandler != null) {
            bossPipeline.addLast("userHandler", parentHandler);
        }

        Channel channel = getFactory().newChannel(bossPipeline);
        final ChannelFuture bfuture = new DefaultChannelFuture(channel, false);
        binder.bindFuture.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess()) {
                    bfuture.setSuccess();
                } else {
                    // Call close on bind failure
                    bfuture.getChannel().close();
                    bfuture.setFailure(future.getCause());
                }
            }
        });
        return bfuture;
    }
View Full Code Here

            for (Map.Entry<String, String> e : customHeaders.entrySet()) {
                request.addHeader(e.getKey(), e.getValue());
            }
        }

        final ChannelFuture handshakeFuture = new DefaultChannelFuture(channel, false);
        ChannelFuture future = channel.write(request);
        future.addListener(new ChannelFutureListener() {

            public void operationComplete(ChannelFuture future) {
                ChannelPipeline p = future.getChannel().getPipeline();
                p.addAfter(
                        p.getContext(HttpRequestEncoder.class).getName(),
                        "ws-encoder", new WebSocket07FrameEncoder(true));

                if (future.isSuccess()) {
                    handshakeFuture.setSuccess();
                } else {
                    handshakeFuture.setFailure(future.getCause());
                }
            }
        });

        return handshakeFuture;
View Full Code Here

            for (Map.Entry<String, String> e: customHeaders.entrySet()) {
                request.addHeader(e.getKey(), e.getValue());
            }
        }

        final ChannelFuture handshakeFuture = new DefaultChannelFuture(channel, false);
        ChannelFuture future = channel.write(request);

        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) {
                ChannelPipeline p = future.getChannel().getPipeline();
                p.replace(HttpRequestEncoder.class, "ws-encoder", new WebSocket08FrameEncoder(true));

                if (future.isSuccess()) {
                    handshakeFuture.setSuccess();
                } else {
                    handshakeFuture.setFailure(future.getCause());
                }
            }
        });

        return handshakeFuture;
View Full Code Here

                request.addHeader(e.getKey(), e.getValue());
            }
        }

        ChannelFuture future = channel.write(request);
        final ChannelFuture handshakeFuture = new DefaultChannelFuture(channel, false);

        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) {
                ChannelPipeline p = future.getChannel().getPipeline();
                p.replace(HttpRequestEncoder.class, "ws-encoder", new WebSocket13FrameEncoder(true));

                if (future.isSuccess()) {
                    handshakeFuture.setSuccess();
                } else {
                    handshakeFuture.setFailure(future.getCause());
                }
            }
        });

        return handshakeFuture;
View Full Code Here

        // Set Content-Length to workaround some known defect.
        // See also: http://www.ietf.org/mail-archive/web/hybi/current/msg02149.html
        request.setHeader(Names.CONTENT_LENGTH, key3.length);
        request.setContent(ChannelBuffers.copiedBuffer(key3));

        final ChannelFuture handshakeFuture = new DefaultChannelFuture(channel, false);
        ChannelFuture future = channel.write(request);

        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) {
                ChannelPipeline p = future.getChannel().getPipeline();
                p.replace(HttpRequestEncoder.class, "ws-encoder", new WebSocket00FrameEncoder());

                if (future.isSuccess()) {
                    handshakeFuture.setSuccess();
                } else {
                    handshakeFuture.setFailure(future.getCause());
                }
            }
        });

        return handshakeFuture;
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.DefaultChannelFuture

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.