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

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

本文整理了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

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

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

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

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

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

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

  1. @Override
  2. public void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
  3. // hold on to the future so that we can determine when the
  4. // caller is notified that the channel has connected
  5. checkState(connectFuture == null, "connectFuture:%s", connectFuture);
  6. connectFuture = e.getFuture();
  7. // create the proxy connect future
  8. // this will be passed on, and we'll respond to it
  9. // and trigger the original future as necessary
  10. ChannelFuture proxyConnectFuture = Channels.future(e.getChannel());
  11. // trigger the original future if the proxy future failed (for whatever reason)
  12. proxyConnectFuture.addListener(new ChannelFutureListener() {
  13. @Override
  14. public void operationComplete(ChannelFuture future) throws Exception {
  15. if (!future.isSuccess()) {
  16. connectFuture.setFailure(future.getCause());
  17. }
  18. }
  19. });
  20. // also trigger the original future if the channel is closed
  21. // I believe the original connect future should be triggered, but just in case....
  22. e.getChannel().getCloseFuture().addListener(new ChannelFutureListener() {
  23. @Override
  24. public void operationComplete(ChannelFuture future) throws Exception {
  25. connectFuture.setFailure(new ClosedChannelException());
  26. }
  27. });
  28. // forward the new connect request
  29. Channels.connect(ctx, proxyConnectFuture, (SocketAddress) e.getValue());
  30. }

相关文章