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

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

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

Channel.setAttachment介绍

[英]Attaches an object to this Channel to store a stateful information
[中]将对象附加到此通道以存储有状态信息

代码示例

代码示例来源:origin: com.ning/async-http-client

public static void setAttribute(Channel channel, Object attribute) {
  channel.setAttachment(attribute);
}

代码示例来源:origin: org.apache.camel/camel-netty

/**
 * To remove the {@link NettyCamelState} stored on the channel,
 * when no longer needed
 */
public void removeState(Channel channel) {
  channel.setAttachment(null);
}

代码示例来源:origin: org.asynchttpclient/async-http-client-netty3

public static void setAttribute(Channel channel, Object attribute) {
  channel.setAttachment(attribute);
}

代码示例来源:origin: io.gatling/async-http-client

public static void setAttribute(Channel channel, Object attribute) {
  channel.setAttachment(attribute);
}

代码示例来源:origin: org.asynchttpclient/async-http-client-netty3-provider

public static void setAttribute(Channel channel, Object attribute) {
  channel.setAttachment(attribute);
}

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

@Override
  public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception {
    e.getChannel().setAttachment(address);
    super.childChannelOpen(ctx, e);
  }
};

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

@Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    checkNotNull(remoteAddress);
    // we assume that the framing handler is downstream,
    // and that the handshake is coming to us in one piece
    ChannelBuffer incomingHandshakeBuffer = (ChannelBuffer) e.getMessage();
    Handshake handshake = getHandshakeFromBuffer(incomingHandshakeBuffer, mapper);
    // set the channel attachment, remove this handler, and then pass a "channelConnected" event on
    ctx.getChannel().setAttachment(handshake.getServerId());
    ctx.getPipeline().remove(this);
    Channels.fireChannelConnected(ctx, remoteAddress);
  }
}

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

@Override
public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception {
  e.getChannel().setAttachment(address);
  childChannels.add(e.getChildChannel());
  super.childChannelOpen(ctx, e);
}

代码示例来源:origin: com.facebook.nifty/nifty-client

msg.readBytes(addr);
ctx.getChannel().setAttachment(new InetSocketAddress(InetAddress.getByAddress(addr), port));

代码示例来源:origin: com.proofpoint.platform/http-client-experimental

msg.readBytes(addr);
ctx.getChannel().setAttachment(new InetSocketAddress(InetAddress.getByAddress(addr), port));

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

channel.setAttachment(serverId); // ONLY store the String name, not the RaftMember object itself!
clusterChannelGroup.add(channel);

代码示例来源:origin: org.apache.camel/camel-netty

channel.setAttachment(new NettyCamelState(producerCallback, exchange));

相关文章