/** * Sends a {@code "write"} request to the * {@link ChannelDownstreamHandler} which is placed in the closest * downstream from the handler associated with the specified * {@link ChannelHandlerContext}. * * @param ctx the context * @param future the future which will be notified when the write * operation is done */ public static void write( ChannelHandlerContext ctx, ChannelFuture future, Object message) { write(ctx, future, message, null); }
public ChannelFuture write(Object message) { return Channels.write(this, message); }
public ChannelFuture write(Object message, SocketAddress remoteAddress) { return Channels.write(this, message, remoteAddress); }
/** * 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 * * @return the {@link ChannelFuture} which will be notified when the * write operation is done */ public static ChannelFuture write(Channel channel, Object message) { return write(channel, message, null); }
public static void write(Channel channel, byte[] body, ChannelFutureListener channelFutureListner) { byte[] header = ByteBuffer.allocate(HEADER_LENGTH).order(ByteOrder.BIG_ENDIAN).putInt(body.length).array(); if (channelFutureListner == null) { Channels.write(channel, ChannelBuffers.wrappedBuffer(header, body)); } else { Channels.write(channel, ChannelBuffers.wrappedBuffer(header, body)).addListener(channelFutureListner); } }
public static void write(Channel channel, ByteBuffer body, ChannelFutureListener channelFutureListner) { byte[] header = ByteBuffer.allocate(HEADER_LENGTH).order(ByteOrder.BIG_ENDIAN).putInt(body.limit()).array(); List<ChannelBuffer> components = new ArrayList<ChannelBuffer>(2); components.add(ChannelBuffers.wrappedBuffer(ByteOrder.BIG_ENDIAN, header)); components.add(ChannelBuffers.wrappedBuffer(body)); if (channelFutureListner == null) { Channels.write(channel, new CompositeChannelBuffer(ByteOrder.BIG_ENDIAN, components)); } else { Channels.write(channel, new CompositeChannelBuffer(ByteOrder.BIG_ENDIAN, components)) .addListener(channelFutureListner); } }
public boolean offer(Object input) { write(getChannel(), input).setSuccess(); return !isEmpty(); } }
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); }
protected boolean doEncode(ChannelHandlerContext ctx, MessageEvent e) throws Exception { Object originalMessage = e.getMessage(); Object encodedMessage = encode(ctx, e.getChannel(), originalMessage); if (originalMessage == encodedMessage) { return false; } if (encodedMessage != null) { write(ctx, e.getFuture(), encodedMessage, e.getRemoteAddress()); } return true; }
Channels.write(ctx, future, composite); return null;
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); } }
SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamId); spdyDataFrame.setLast(true); Channels.write(ctx, future, spdyDataFrame, remoteAddress); } else { spdyHeadersFrame.headers().add(entry.getKey(), entry.getValue()); Channels.write(ctx, future, spdyHeadersFrame, remoteAddress); Channels.write(ctx, future, spdyDataFrame, remoteAddress);
currentStreamId = spdySynStreamFrame.getStreamId(); ChannelFuture future = getMessageFuture(ctx, e, currentStreamId, httpRequest); Channels.write(ctx, future, spdySynStreamFrame, e.getRemoteAddress()); currentStreamId = spdySynStreamFrame.getStreamId(); ChannelFuture future = getMessageFuture(ctx, e, currentStreamId, httpResponse); Channels.write(ctx, future, spdySynStreamFrame, e.getRemoteAddress()); } else { SpdySynReplyFrame spdySynReplyFrame = createSynReplyFrame(httpResponse); currentStreamId = spdySynReplyFrame.getStreamId(); ChannelFuture future = getMessageFuture(ctx, e, currentStreamId, httpResponse); Channels.write(ctx, future, spdySynReplyFrame, e.getRemoteAddress());
write(ctx, future, msg);
write(ctx, succeededFuture(ctx.getChannel()), CONTINUE.duplicate());
Channels.write(ctx, future, footer);
write( ctx, writeFuture, chunk, currentEvent.getRemoteAddress());
Channels.write(ctx, future, footer);
Channels.write( ctx, Channels.succeededFuture(e.getChannel()), new DefaultHttpChunk(lastProduct), e.getRemoteAddress());