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

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

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

Channels.succeededFuture介绍

[英]Creates a new ChannelFuture which is already succeeded for the specified Channel.
[中]创建新ChannelFuture,该新ChannelFuture已成功用于指定的通道。

代码示例

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

@Override
protected void close(SelectionKey k) {
  AbstractNioChannel<?> ch = (AbstractNioChannel<?>) k.attachment();
  close(ch, succeededFuture(ch));
}

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

@Override
protected void close(SelectionKey k) {
  NioServerSocketChannel ch = (NioServerSocketChannel) k.attachment();
  close(ch, succeededFuture(ch));
}

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

@Override
protected void close(SelectionKey k) {
  NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
  ch.worker.close(ch, succeededFuture(ch));
}

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

public ChannelFuture getFuture() {
  return succeededFuture(getChannel());
}

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

public ChannelFuture getFuture() {
  return succeededFuture(getChannel());
}

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

public ChannelFuture getFuture() {
  return succeededFuture(getChannel());
}

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

public ChannelFuture getFuture() {
  return succeededFuture(getChannel());
}

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

public ChannelFuture getFuture() {
  return succeededFuture(getChannel());
}

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

public ChannelFuture getFuture() {
  return succeededFuture(getChannel());
}

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

public ChannelFuture joinGroup(InetAddress multicastAddress) {
  ensureBound();
  try {
    socket.joinGroup(multicastAddress);
    return succeededFuture(this);
  } catch (IOException e) {
    return failedFuture(this, e);
  }
}

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

public ChannelFuture joinGroup(
    InetSocketAddress multicastAddress, NetworkInterface networkInterface) {
  ensureBound();
  try {
    socket.joinGroup(multicastAddress, networkInterface);
    return succeededFuture(this);
  } catch (IOException e) {
    return failedFuture(this, e);
  }
}

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

public ChannelFuture leaveGroup(InetAddress multicastAddress) {
  try {
    socket.leaveGroup(multicastAddress);
    return succeededFuture(this);
  } catch (IOException e) {
    return failedFuture(this, e);
  }
}

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

public ChannelFuture leaveGroup(
    InetSocketAddress multicastAddress, NetworkInterface networkInterface) {
  try {
    socket.leaveGroup(multicastAddress, networkInterface);
    return succeededFuture(this);
  } catch (IOException e) {
    return failedFuture(this, e);
  }
}

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

/**
 * Block the given sourceToBlock address for the given multicastAddress
 *
 */
public ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock) {
  try {
    block(multicastAddress, NetworkInterface.getByInetAddress(getLocalAddress().getAddress()), sourceToBlock);
  } catch (SocketException e) {
    return failedFuture(this, e);
  }
  return succeededFuture(this);
}

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

/**
   * This implementation just directly call {@link Runnable#run()}.
   * Sub-classes should override this if they can handle it in a better way
   */
  public ChannelFuture execute(ChannelPipeline pipeline, Runnable task) {
    try {
      task.run();
      return succeededFuture(pipeline.getChannel());
    } catch (Throwable t) {
      return failedFuture(pipeline.getChannel(), t);
    }
  }
}

代码示例来源: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

private void processSelectedKeys(Set<SelectionKey> selectedKeys) {
  // check if the set is empty and if so just return to not create garbage by
  // creating a new Iterator every time even if there is nothing to process.
  // See https://github.com/netty/netty/issues/597
  if (selectedKeys.isEmpty()) {
    return;
  }
  for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
    SelectionKey k = i.next();
    i.remove();
    if (!k.isValid()) {
      close(k);
      continue;
    }
    try {
      if (k.isConnectable()) {
        connect(k);
      }
    } catch (Throwable t) {
      NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
      ch.connectFuture.setFailure(t);
      fireExceptionCaught(ch, t);
      k.cancel(); // Some JDK implementations run into an infinite loop without this.
      ch.worker.close(ch, succeededFuture(ch));
    }
  }
}

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

public void run() {
    int timeout = channel.getConfig().getConnectTimeoutMillis();
    if (timeout > 0) {
      if (!channel.isConnected()) {
        channel.timoutTimer = timer.newTimeout(wakeupTask,
            timeout, TimeUnit.MILLISECONDS);
      }
    }
    try {
      channel.channel.register(
          boss.selector, SelectionKey.OP_CONNECT, channel);
    } catch (ClosedChannelException e) {
      channel.worker.close(channel, succeededFuture(channel));
    }
    int connectTimeout = channel.getConfig().getConnectTimeoutMillis();
    if (connectTimeout > 0) {
      channel.connectDeadlineNanos = System.nanoTime() + connectTimeout * 1000000L;
    }
  }
}

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

future.setFailure(new ClosedChannelException());
close(channel, succeededFuture(channel));
return;
  future.setFailure(e);
close(channel, succeededFuture(channel));

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

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  if (!readingChunks) {
    HttpResponse res = (HttpResponse) e.getMessage();
    if (res.getStatus().getCode() != HttpResponseStatus.OK.getCode()) {
      throw new ChannelException("Unexpected HTTP response status: " + res.getStatus());
    }
    if (res.isChunked()) {
      readingChunks = true;
    } else {
      ChannelBuffer content = res.getContent();
      if (content.readable()) {
        fireMessageReceived(HttpTunnelingClientSocketChannel.this, content);
      }
      // Reached to the end of response - close the request.
      closeReal(succeededFuture(virtualChannel));
    }
  } else {
    HttpChunk chunk = (HttpChunk) e.getMessage();
    if (!chunk.isLast()) {
      fireMessageReceived(HttpTunnelingClientSocketChannel.this, chunk.getContent());
    } else {
      readingChunks = false;
      // Reached to the end of response - close the request.
      closeReal(succeededFuture(virtualChannel));
    }
  }
}

相关文章