/** * Creates a new non-cancellable {@link ChannelFuture} for the specified * {@link Channel}. */ public static ChannelFuture future(Channel channel) { return future(channel, false); }
private void setHandshakeSuccess(Channel channel) { synchronized (handshakeLock) { handshaking = false; handshaken = true; if (handshakeFuture == null) { handshakeFuture = future(channel); } cancelHandshakeTimeout(); } if (logger.isDebugEnabled()) { logger.debug(channel + " HANDSHAKEN: " + engine.getSession().getCipherSuite()); } handshakeFuture.setSuccess(); }
private synchronized ChannelFuture sendGoAwayFrame( ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, SpdySessionStatus status) { if (!sentGoAwayFrame) { sentGoAwayFrame = true; SpdyGoAwayFrame spdyGoAwayFrame = new DefaultSpdyGoAwayFrame(lastGoodStreamId, status); ChannelFuture future = Channels.future(channel); Channels.write(ctx, future, spdyGoAwayFrame, remoteAddress); return future; } return Channels.succeededFuture(channel); }
/** * Sends a {@code "bind"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to bind * @param localAddress the local address to bind to * * @return the {@link ChannelFuture} which will be notified when the * bind operation is done */ public static ChannelFuture bind(Channel channel, SocketAddress localAddress) { if (localAddress == null) { throw new NullPointerException("localAddress"); } ChannelFuture future = future(channel); channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent( channel, future, ChannelState.BOUND, localAddress)); return future; }
/** * Sends a {@code "connect"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to attempt a connection * @param remoteAddress the remote address to connect to * * @return the {@link ChannelFuture} which will be notified when the * connection attempt is done */ public static ChannelFuture connect(Channel channel, SocketAddress remoteAddress) { if (remoteAddress == null) { throw new NullPointerException("remoteAddress"); } ChannelFuture future = future(channel, true); channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent( channel, future, ChannelState.CONNECTED, remoteAddress)); return future; }
/** * Sends a {@code "disconnect"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to disconnect * * @return the {@link ChannelFuture} which will be notified on disconnection */ public static ChannelFuture disconnect(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent( channel, future, ChannelState.CONNECTED, null)); return future; }
/** * Sends a {@code "unbind"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to unbind * * @return the {@link ChannelFuture} which will be notified when the * unbind operation is done */ public static ChannelFuture unbind(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent( channel, future, ChannelState.BOUND, null)); return future; }
/** * Sends a {@code "write"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to write a message * @param message the message to write to the channel * @param remoteAddress the destination of the message. * {@code null} to use the default remote address * * @return the {@link ChannelFuture} which will be notified when the * write operation is done */ public static ChannelFuture write(Channel channel, Object message, SocketAddress remoteAddress) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream( new DownstreamMessageEvent(channel, future, message, remoteAddress)); return future; }
ChannelFuture future = Channels.future(ctx.getChannel()); future.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future)
pipeline.addFirst("ssl", sslHandler); final ChannelFuture handshakeFuture = Channels.future(connectFuture.getChannel()); pipeline.addLast("connectionErrorHandler", new SimpleChannelUpstreamHandler()
public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { Throwable cause = future.getCause(); hsFuture.setFailure(cause); fireExceptionCaught(ctx, cause); if (closeOnSslException) { Channels.close(ctx, future(channel)); } } } });
private void setHandshakeFailure(Channel channel, SSLException cause) { synchronized (handshakeLock) { if (!handshaking) { return; } handshaking = false; handshaken = false; if (handshakeFuture == null) { handshakeFuture = future(channel); } // cancel the timeout now cancelHandshakeTimeout(); // Release all resources such as internal buffers that SSLEngine // is managing. engine.closeOutbound(); try { engine.closeInbound(); } catch (SSLException e) { if (logger.isDebugEnabled()) { logger.debug( "SSLEngine.closeInbound() raised an exception after " + "a handshake failure.", e); } } } handshakeFuture.setFailure(cause); if (closeOnSslException) { Channels.close(ctx, future(channel)); } }
private void issueStreamError( ChannelHandlerContext ctx, SocketAddress remoteAddress, int streamId, SpdyStreamStatus status) { boolean fireMessageReceived = !spdySession.isRemoteSideClosed(streamId); ChannelFuture future = Channels.future(ctx.getChannel()); removeStream(streamId, future); SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status); Channels.write(ctx, future, spdyRstStreamFrame, remoteAddress); if (fireMessageReceived) { Channels.fireMessageReceived(ctx, spdyRstStreamFrame, remoteAddress); } }
private static ChannelFuture getDataFuture( ChannelHandlerContext ctx, ChannelFuture future, SpdyDataFrame[] spdyDataFrames, SocketAddress remoteAddress) { ChannelFuture dataFuture = future; for (int i = spdyDataFrames.length; --i >= 0;) { future = Channels.future(ctx.getChannel()); future.addListener(new SpdyFrameWriter(ctx, new DownstreamMessageEvent( ctx.getChannel(), dataFuture, spdyDataFrames[i], remoteAddress))); dataFuture = future; } return dataFuture; }
/** * Sends a {@code "setInterestOps"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to change its interestOps * @param interestOps the new interestOps * * @return the {@link ChannelFuture} which will be notified when the * interestOps is changed */ public static ChannelFuture setInterestOps(Channel channel, int interestOps) { validateInterestOps(interestOps); interestOps = filterDownstreamInterestOps(interestOps); ChannelFuture future = future(channel); channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent( channel, future, ChannelState.INTEREST_OPS, interestOps)); return future; }
/** * Sends an SSL {@code close_notify} message to the specified channel and * destroys the underlying {@link SSLEngine}. */ public ChannelFuture close() { ChannelHandlerContext ctx = this.ctx; Channel channel = ctx.getChannel(); try { engine.closeOutbound(); return wrapNonAppData(ctx, channel); } catch (SSLException e) { fireExceptionCaught(ctx, e); if (closeOnSslException) { Channels.close(ctx, future(channel)); } return failedFuture(channel, e); } }
engine.beginHandshake(); runDelegatedTasks(); handshakeFuture = this.handshakeFuture = future(channel); if (handshakeTimeoutInMillis > 0) { handshakeTimeout = timer.newTimeout(new TimerTask() { Channels.close(ctx, future(channel)); fireExceptionCaught(ctx, exception); if (closeOnSslException) { Channels.close(ctx, future(channel));
future = Channels.future(ctx.getChannel()); Channels.write(ctx, future, footer);
partialDataFrame.setData(spdyDataFrame.getData().readSlice(newWindowSize)); ChannelFuture writeFuture = Channels.future(e.getChannel());