Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFuture.addListener()


    }
    else
    {
      // Write failure and close channel.
      ChannelFuture future = channel.write(NettyUtils.createBufferForOpcode(Events.GAME_ROOM_JOIN_FAILURE));
      future.addListener(ChannelFutureListener.CLOSE);
      LOG.error("Invalid ref key provided by client: {}. Channel {} will be closed",refKey,channel.getId());
    }
  }
 
  protected void handleReJoin(PlayerSession playerSession, GameRoom gameRoom, Channel channel,
View Full Code Here


    }
    else
    {
      f = e.getChannel().write(this.getPolicyFileContents());
    }
    f.addListener(ChannelFutureListener.CLOSE);
  }

    public ChannelBuffer getPolicyFileContents() throws Exception {
     
        return ChannelBuffers.copiedBuffer(
View Full Code Here

    else
    {
      // Write failure and close channel.
      ChannelFuture future = channel.write(eventToFrame(
          Events.GAME_ROOM_JOIN_FAILURE, null));
      future.addListener(ChannelFutureListener.CLOSE);
      LOG.error(
          "Invalid ref key provided by client: {}. Channel {} will be closed",
          refKey, channel.getId());
    }
  }
View Full Code Here

    ChannelFuture future;
    synchronized (bootstrap)
    {
      bootstrap.setPipelineFactory(pipelineFactory);
      future = bootstrap.connect(serverAddress);
      future.addListener(new ChannelFutureListener()
      {
        @Override
        public void operationComplete(ChannelFuture future)
            throws Exception
        {
View Full Code Here

        if (requests == null)
            return;

        pendings.incrementAndGet();
        ChannelFuture future = channel.write(requests);
        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future)
                    throws Exception {

                pendings.decrementAndGet();
                if (!future.isSuccess()) {
View Full Code Here

        ChannelFuture future = con.sendMessage(response);

        // Close the non-keep-alive connection after the write operation is done.
        if (!isStrest) {
//          log.info("CLOSING NON STREST CONNECTION");
            future.addListener(ChannelFutureListener.CLOSE);
            this.removeChannel(channel);
        }
  }
}
View Full Code Here

     String response = "<cross-domain-policy>" +
         "<allow-access-from domain=\"*\" to-ports=\"*\" />" +
         "</cross-domain-policy>";
     ChannelFuture future = e.getChannel().write(ChannelBuffers.wrappedBuffer(response.getBytes("utf8")));
     //disconnect..
     future.addListener(ChannelFutureListener.CLOSE);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
            throws Exception {
View Full Code Here

        if (footer != null) {
            Channels.write(ctx, future, footer);
        }

        if (evt != null) {
            future.addListener(new ChannelFutureListener() {
                public void operationComplete(ChannelFuture future) throws Exception {
                    ctx.sendDownstream(evt);
                }
            });
        }
View Full Code Here

                    ChannelBuffer msg = ChannelBuffers.buffer(outNetBuf.remaining());
                    msg.writeBytes(outNetBuf.array(), 0, msg.capacity());
                    outNetBuf.clear();

                    future = future(channel);
                    future.addListener(new ChannelFutureListener() {
                        public void operationComplete(ChannelFuture future)
                                throws Exception {
                            if (future.getCause() instanceof ClosedChannelException) {
                                synchronized (ignoreClosedChannelExceptionLock) {
                                    ignoreClosedChannelException ++;
View Full Code Here

        unwrap(context, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
        if (!engine.isInboundDone()) {
            if (sentCloseNotify.compareAndSet(false, true)) {
                engine.closeOutbound();
                ChannelFuture closeNotifyFuture = wrapNonAppData(context, e.getChannel());
                closeNotifyFuture.addListener(
                        new ClosingChannelFutureListener(context, e));
                return;
            }
        }
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.