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

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

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

Channels.future介绍

[英]Creates a new non-cancellable ChannelFuture for the specified Channel.
[中]为指定的频道创建新的不可取消的ChannelFuture。

代码示例

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

  1. /**
  2. * Creates a new non-cancellable {@link ChannelFuture} for the specified
  3. * {@link Channel}.
  4. */
  5. public static ChannelFuture future(Channel channel) {
  6. return future(channel, false);
  7. }

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

  1. private void setHandshakeSuccess(Channel channel) {
  2. synchronized (handshakeLock) {
  3. handshaking = false;
  4. handshaken = true;
  5. if (handshakeFuture == null) {
  6. handshakeFuture = future(channel);
  7. }
  8. cancelHandshakeTimeout();
  9. }
  10. if (logger.isDebugEnabled()) {
  11. logger.debug(channel + " HANDSHAKEN: " + engine.getSession().getCipherSuite());
  12. }
  13. handshakeFuture.setSuccess();
  14. }

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

  1. private synchronized ChannelFuture sendGoAwayFrame(
  2. ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, SpdySessionStatus status) {
  3. if (!sentGoAwayFrame) {
  4. sentGoAwayFrame = true;
  5. SpdyGoAwayFrame spdyGoAwayFrame = new DefaultSpdyGoAwayFrame(lastGoodStreamId, status);
  6. ChannelFuture future = Channels.future(channel);
  7. Channels.write(ctx, future, spdyGoAwayFrame, remoteAddress);
  8. return future;
  9. }
  10. return Channels.succeededFuture(channel);
  11. }

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

  1. /**
  2. * Sends a {@code "bind"} request to the last
  3. * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
  4. * the specified {@link Channel}.
  5. *
  6. * @param channel the channel to bind
  7. * @param localAddress the local address to bind to
  8. *
  9. * @return the {@link ChannelFuture} which will be notified when the
  10. * bind operation is done
  11. */
  12. public static ChannelFuture bind(Channel channel, SocketAddress localAddress) {
  13. if (localAddress == null) {
  14. throw new NullPointerException("localAddress");
  15. }
  16. ChannelFuture future = future(channel);
  17. channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
  18. channel, future, ChannelState.BOUND, localAddress));
  19. return future;
  20. }

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

  1. /**
  2. * Sends a {@code "connect"} request to the last
  3. * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
  4. * the specified {@link Channel}.
  5. *
  6. * @param channel the channel to attempt a connection
  7. * @param remoteAddress the remote address to connect to
  8. *
  9. * @return the {@link ChannelFuture} which will be notified when the
  10. * connection attempt is done
  11. */
  12. public static ChannelFuture connect(Channel channel, SocketAddress remoteAddress) {
  13. if (remoteAddress == null) {
  14. throw new NullPointerException("remoteAddress");
  15. }
  16. ChannelFuture future = future(channel, true);
  17. channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
  18. channel, future, ChannelState.CONNECTED, remoteAddress));
  19. return future;
  20. }

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

  1. /**
  2. * Sends a {@code "disconnect"} request to the last
  3. * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
  4. * the specified {@link Channel}.
  5. *
  6. * @param channel the channel to disconnect
  7. *
  8. * @return the {@link ChannelFuture} which will be notified on disconnection
  9. */
  10. public static ChannelFuture disconnect(Channel channel) {
  11. ChannelFuture future = future(channel);
  12. channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
  13. channel, future, ChannelState.CONNECTED, null));
  14. return future;
  15. }

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

  1. /**
  2. * Sends a {@code "unbind"} request to the last
  3. * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
  4. * the specified {@link Channel}.
  5. *
  6. * @param channel the channel to unbind
  7. *
  8. * @return the {@link ChannelFuture} which will be notified when the
  9. * unbind operation is done
  10. */
  11. public static ChannelFuture unbind(Channel channel) {
  12. ChannelFuture future = future(channel);
  13. channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
  14. channel, future, ChannelState.BOUND, null));
  15. return future;
  16. }

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

  1. /**
  2. * Sends a {@code "write"} request to the last
  3. * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
  4. * the specified {@link Channel}.
  5. *
  6. * @param channel the channel to write a message
  7. * @param message the message to write to the channel
  8. * @param remoteAddress the destination of the message.
  9. * {@code null} to use the default remote address
  10. *
  11. * @return the {@link ChannelFuture} which will be notified when the
  12. * write operation is done
  13. */
  14. public static ChannelFuture write(Channel channel, Object message, SocketAddress remoteAddress) {
  15. ChannelFuture future = future(channel);
  16. channel.getPipeline().sendDownstream(
  17. new DownstreamMessageEvent(channel, future, message, remoteAddress));
  18. return future;
  19. }

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

  1. ChannelFuture future = Channels.future(ctx.getChannel());
  2. future.addListener(new ChannelFutureListener() {
  3. public void operationComplete(ChannelFuture future)

代码示例来源:origin: apache/incubator-druid

  1. pipeline.addFirst("ssl", sslHandler);
  2. final ChannelFuture handshakeFuture = Channels.future(connectFuture.getChannel());
  3. pipeline.addLast("connectionErrorHandler", new SimpleChannelUpstreamHandler()

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

  1. public void operationComplete(ChannelFuture future) throws Exception {
  2. if (!future.isSuccess()) {
  3. Throwable cause = future.getCause();
  4. hsFuture.setFailure(cause);
  5. fireExceptionCaught(ctx, cause);
  6. if (closeOnSslException) {
  7. Channels.close(ctx, future(channel));
  8. }
  9. }
  10. }
  11. });

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

  1. private void setHandshakeFailure(Channel channel, SSLException cause) {
  2. synchronized (handshakeLock) {
  3. if (!handshaking) {
  4. return;
  5. }
  6. handshaking = false;
  7. handshaken = false;
  8. if (handshakeFuture == null) {
  9. handshakeFuture = future(channel);
  10. }
  11. // cancel the timeout now
  12. cancelHandshakeTimeout();
  13. // Release all resources such as internal buffers that SSLEngine
  14. // is managing.
  15. engine.closeOutbound();
  16. try {
  17. engine.closeInbound();
  18. } catch (SSLException e) {
  19. if (logger.isDebugEnabled()) {
  20. logger.debug(
  21. "SSLEngine.closeInbound() raised an exception after " +
  22. "a handshake failure.", e);
  23. }
  24. }
  25. }
  26. handshakeFuture.setFailure(cause);
  27. if (closeOnSslException) {
  28. Channels.close(ctx, future(channel));
  29. }
  30. }

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

  1. private void issueStreamError(
  2. ChannelHandlerContext ctx, SocketAddress remoteAddress, int streamId, SpdyStreamStatus status) {
  3. boolean fireMessageReceived = !spdySession.isRemoteSideClosed(streamId);
  4. ChannelFuture future = Channels.future(ctx.getChannel());
  5. removeStream(streamId, future);
  6. SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status);
  7. Channels.write(ctx, future, spdyRstStreamFrame, remoteAddress);
  8. if (fireMessageReceived) {
  9. Channels.fireMessageReceived(ctx, spdyRstStreamFrame, remoteAddress);
  10. }
  11. }

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

  1. private static ChannelFuture getDataFuture(
  2. ChannelHandlerContext ctx, ChannelFuture future,
  3. SpdyDataFrame[] spdyDataFrames, SocketAddress remoteAddress) {
  4. ChannelFuture dataFuture = future;
  5. for (int i = spdyDataFrames.length; --i >= 0;) {
  6. future = Channels.future(ctx.getChannel());
  7. future.addListener(new SpdyFrameWriter(ctx, new DownstreamMessageEvent(
  8. ctx.getChannel(), dataFuture, spdyDataFrames[i], remoteAddress)));
  9. dataFuture = future;
  10. }
  11. return dataFuture;
  12. }

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

  1. /**
  2. * Sends a {@code "setInterestOps"} request to the last
  3. * {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
  4. * the specified {@link Channel}.
  5. *
  6. * @param channel the channel to change its interestOps
  7. * @param interestOps the new interestOps
  8. *
  9. * @return the {@link ChannelFuture} which will be notified when the
  10. * interestOps is changed
  11. */
  12. public static ChannelFuture setInterestOps(Channel channel, int interestOps) {
  13. validateInterestOps(interestOps);
  14. interestOps = filterDownstreamInterestOps(interestOps);
  15. ChannelFuture future = future(channel);
  16. channel.getPipeline().sendDownstream(new DownstreamChannelStateEvent(
  17. channel, future, ChannelState.INTEREST_OPS, interestOps));
  18. return future;
  19. }

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

  1. /**
  2. * Sends an SSL {@code close_notify} message to the specified channel and
  3. * destroys the underlying {@link SSLEngine}.
  4. */
  5. public ChannelFuture close() {
  6. ChannelHandlerContext ctx = this.ctx;
  7. Channel channel = ctx.getChannel();
  8. try {
  9. engine.closeOutbound();
  10. return wrapNonAppData(ctx, channel);
  11. } catch (SSLException e) {
  12. fireExceptionCaught(ctx, e);
  13. if (closeOnSslException) {
  14. Channels.close(ctx, future(channel));
  15. }
  16. return failedFuture(channel, e);
  17. }
  18. }

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

  1. engine.beginHandshake();
  2. runDelegatedTasks();
  3. handshakeFuture = this.handshakeFuture = future(channel);
  4. if (handshakeTimeoutInMillis > 0) {
  5. handshakeTimeout = timer.newTimeout(new TimerTask() {
  6. Channels.close(ctx, future(channel));
  7. fireExceptionCaught(ctx, exception);
  8. if (closeOnSslException) {
  9. Channels.close(ctx, future(channel));

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

  1. footer = null;
  2. } else if (z.next_out_index != 0) {
  3. future = Channels.future(ctx.getChannel());
  4. footer =
  5. ctx.getChannel().getConfig().getBufferFactory().getBuffer(
  6. future = Channels.future(ctx.getChannel());
  7. footer = ChannelBuffers.EMPTY_BUFFER;

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

  1. future = Channels.future(ctx.getChannel());
  2. Channels.write(ctx, future, footer);

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

  1. partialDataFrame.setData(spdyDataFrame.getData().readSlice(newWindowSize));
  2. ChannelFuture writeFuture = Channels.future(e.getChannel());

相关文章