/** * 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 "close"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to close * * @return the {@link ChannelFuture} which will be notified on closure */ public static ChannelFuture close(Channel channel) { ChannelFuture future = channel.getCloseFuture(); channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent( channel, future, ChannelState.OPEN, Boolean.FALSE)); 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; }
/** * 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; }
public void sendDownstream(Object message) { if (message instanceof ChannelEvent) { this.pipeline.sendDownstream( (ChannelEvent) message ); } else { Channels.write( this.channel, message ); } }
public static ChannelFuture abortOutput(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream( new DownstreamWriteAbortEvent(channel, future)); return future; }
public static ChannelFuture abortInput(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream( new DownstreamReadAbortEvent(channel, future)); return future; }
/** * Sends a {@code "shutdownOutput"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to bind * * @return the {@link ChannelFuture} which will be notified when the * shutdownOutput operation is done */ public static ChannelFuture shutdownOutput(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream( new DownstreamShutdownOutputEvent(channel, future)); return future; }
/** * Sends a {@code "shutdownInput"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to bind * * @return the {@link ChannelFuture} which will be notified when the * shutdownInput operation is done */ public static ChannelFuture shutdownInput(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream( new DownstreamShutdownInputEvent(channel, future)); return future; }
/** * Sends a {@code "flush"} request to the last * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param channel the channel to bind * * @return the {@link ChannelFuture} which will be notified when the * flush operation is done */ public static ChannelFuture flush(Channel channel) { ChannelFuture future = future(channel); channel.getPipeline().sendDownstream( new DownstreamFlushEvent(channel, future)); return future; }
pipeline.sendDownstream(writeRequest); pipeline.sendDownstream(writeRequest);
new OrderedDownstreamChannelEvent(orderedUpstreamMessageEvent, 0, true, resp); future = downstreamChannelEvent.getFuture(); channel.getPipeline().sendDownstream(downstreamChannelEvent); } else { future = channel.write(resp);