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

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

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

Channels.connect介绍

[英]Sends a "connect" request to the last ChannelDownstreamHandler in the ChannelPipeline of the specified Channel.
[中]将“连接”请求发送到指定通道的ChannelPipeline中的最后一个ChannelDownstreamHandler。

代码示例

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

public ChannelFuture connect(SocketAddress remoteAddress) {
  return Channels.connect(this, remoteAddress);
}

代码示例来源:origin: kaazing/gateway

public ChannelFuture connect(SocketAddress remoteAddress) {
  return Channels.connect(this, remoteAddress);
}

代码示例来源:origin: k3po/k3po

@Override
protected void invokeCommand(ChannelHandlerContext ctx) throws Exception {
  ChannelFuture handlerFuture = getHandlerFuture();
  Channels.connect(ctx, handlerFuture, remoteAddress);
}

代码示例来源:origin: io.libraft/libraft-agent

@Override
public void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
  // hold on to the future so that we can determine when the
  // caller is notified that the channel has connected
  checkState(connectFuture == null, "connectFuture:%s", connectFuture);
  connectFuture = e.getFuture();
  // create the proxy connect future
  // this will be passed on, and we'll respond to it
  // and trigger the original future as necessary
  ChannelFuture proxyConnectFuture = Channels.future(e.getChannel());
  // trigger the original future if the proxy future failed (for whatever reason)
  proxyConnectFuture.addListener(new ChannelFutureListener() {
    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
      if (!future.isSuccess()) {
        connectFuture.setFailure(future.getCause());
      }
    }
  });
  // also trigger the original future if the channel is closed
  // I believe the original connect future should be triggered, but just in case....
  e.getChannel().getCloseFuture().addListener(new ChannelFutureListener() {
    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
      connectFuture.setFailure(new ClosedChannelException());
    }
  });
  // forward the new connect request
  Channels.connect(ctx, proxyConnectFuture, (SocketAddress) e.getValue());
}

相关文章