org.jboss.netty.channel.Channels.write()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(332)

本文整理了Java中org.jboss.netty.channel.Channels.write()方法的一些代码示例,展示了Channels.write()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channels.write()方法的具体详情如下:
包路径:org.jboss.netty.channel.Channels
类名称:Channels
方法名:write

Channels.write介绍

[英]Sends a "write" request to the last ChannelDownstreamHandler in the ChannelPipeline of the specified Channel.
[中]向指定通道的ChannelPipeline中的最后一个ChannelDownstreamHandler发送“写入”请求。

代码示例

代码示例来源:origin: io.netty/netty

/**
 * 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);
}

代码示例来源:origin: io.netty/netty

public ChannelFuture write(Object message) {
  return Channels.write(this, message);
}

代码示例来源:origin: io.netty/netty

public ChannelFuture write(Object message, SocketAddress remoteAddress) {
  return Channels.write(this, message, remoteAddress);
}

代码示例来源:origin: io.netty/netty

/**
 * 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);
}

代码示例来源:origin: alibaba/canal

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);
  }
}

代码示例来源:origin: alibaba/canal

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);
  }
}

代码示例来源:origin: io.netty/netty

public boolean offer(Object input) {
    write(getChannel(), input).setSuccess();
    return !isEmpty();
  }
}

代码示例来源:origin: io.netty/netty

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);
}

代码示例来源:origin: io.netty/netty

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;
}

代码示例来源:origin: io.netty/netty

Channels.write(ctx, future, composite);
return null;

代码示例来源:origin: io.netty/netty

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);
  }
}

代码示例来源:origin: io.netty/netty

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);

代码示例来源:origin: io.netty/netty

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());

代码示例来源:origin: io.netty/netty

write(ctx, future, msg);

代码示例来源:origin: io.netty/netty

write(ctx, succeededFuture(ctx.getChannel()), CONTINUE.duplicate());

代码示例来源:origin: io.netty/netty

Channels.write(ctx, future, footer);

代码示例来源:origin: io.netty/netty

Channels.write(ctx, e.getFuture(), spdyDataFrame, e.getRemoteAddress());
} else {
  Channels.write(ctx, writeFuture, partialDataFrame, remoteAddress);

代码示例来源:origin: io.netty/netty

write(
    ctx, writeFuture, chunk,
    currentEvent.getRemoteAddress());

代码示例来源:origin: io.netty/netty

Channels.write(ctx, future, footer);

代码示例来源:origin: io.netty/netty

Channels.write(
    ctx, Channels.succeededFuture(e.getChannel()),
    new DefaultHttpChunk(lastProduct), e.getRemoteAddress());

相关文章