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

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

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

Channels.fireChannelConnected介绍

[英]Sends a "channelConnected" event to the first ChannelUpstreamHandler in the ChannelPipeline of the specified Channel.
[中]将“channelConnected”事件发送到指定通道的ChannelPipeline中的第一个ChannelUpstreamHandler。

代码示例

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

@Override
public void run() {
  boolean fireConnected = channel instanceof OioAcceptedSocketChannel;
  if (fireConnected && channel.isOpen()) {
    // Fire the channelConnected event for OioAcceptedSocketChannel.
    // See #287
    fireChannelConnected(channel, channel.getRemoteAddress());
  }
  super.run();
}

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

private void fireInitialEvents() {
  // Fire the typical initial events.
  fireChannelOpen(channel);
  fireChannelBound(channel, channel.getLocalAddress());
  fireChannelConnected(channel, channel.getRemoteAddress());
}

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

fireChannelBound(channel, channel.getLocalAddress());
fireChannelConnected(channel, channel.getRemoteAddress());

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

fireChannelBound(channel, localAddress);
  fireChannelConnected(channel, remoteAddress);
} catch (IOException e) {
  if (future != null) {

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

requestHeaderWritten = true;
  future.setSuccess();
  fireChannelConnected(virtualChannel, remoteAddress);
} else {
  sslHandshakeFuture.addListener(new ChannelFutureListener() {

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

fireChannelConnected(channel, serverChannel.getLocalAddress());
acceptedChannel.remoteAddress = channel.getLocalAddress();
acceptedChannel.setConnected();
fireChannelConnected(acceptedChannel, channel.getLocalAddress());

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

fireChannelBound(channel, channel.getLocalAddress());
fireChannelConnected(channel, channel.getRemoteAddress());

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

fireChannelBound(channel, channel.getLocalAddress());
fireChannelConnected(channel, channel.getRemoteAddress());

代码示例来源: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 run() {
  clientChannel.setRemoteAddress(remoteAddress);
  clientChannel.setConnected();
  fireChannelConnected(clientChannel, clientChannel.getRemoteAddress());
  connectFuture.setSuccess();
  clientChannel.worker.register(clientChannel);
}

代码示例来源:origin: projectodd/stilts

private void fireInitialEvents() {
  // Fire the typical initial events.
  fireChannelOpen( channel );
  fireChannelBound( channel, channel.getLocalAddress() );
  fireChannelConnected( channel, channel.getRemoteAddress() );
}

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

fireChannelConnected(channel, remoteAddress);
} catch (final IOException e) {
  if (future != null) {

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

fireChannelConnected(channel, remoteAddress);
} catch (final IOException e) {
  if (future != null) {

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

@Override
@SuppressWarnings("unchecked")
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  S serverChannel = (S) ctx.getAttachment();
  T childChannel = createChildChannel(serverChannel, e.getChannel());
  fireChannelOpen(childChannel);
  ChannelAddress localAddress = serverChannel.getLocalAddress();
  childChannel.setLocalAddress(localAddress);
  childChannel.setBound();
  fireChannelBound(childChannel, localAddress);
  ctx.setAttachment(childChannel);
  ctx.sendUpstream(e);
  // TODO: fire CONNECTED_BARRIER event to next pipeline
  // then fire CONNECTED event when future completes successfully
  ChannelAddress remoteAddress = localAddress.newEphemeralAddress();
  childChannel.setRemoteAddress(remoteAddress);
  childChannel.setConnected();
  fireChannelConnected(childChannel, remoteAddress);
}

代码示例来源:origin: net.sourceforge.openutils/flazr

@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer in) {               
  if(in.readableBytes() < 1 + RtmpHandshake.HANDSHAKE_SIZE * 2) {
    return null;
  }
  handshake.decodeServerAll(in);
  Channels.write(ctx, Channels.succeededFuture(channel), handshake.encodeClient2());
  handshakeDone = true;
  rtmpe = handshake.isRtmpe(); // rare chance server refused rtmpe
  if(handshake.getSwfvBytes() != null) {
    ClientHandler clientHandler = channel.getPipeline().get(ClientHandler.class);
    clientHandler.setSwfvBytes(handshake.getSwfvBytes());
  }
  if(!rtmpe) {
    channel.getPipeline().remove(this);
  }
  Channels.fireChannelConnected(ctx, channel.getRemoteAddress());
  return in;
}

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

childChannel.setRemoteAddress(address);
childChannel.setConnected();
fireChannelConnected(childChannel, e.getRemoteAddress());

代码示例来源:origin: mconf/flazr

@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer in) {               
  if(in.readableBytes() < 1 + RtmpHandshake.HANDSHAKE_SIZE * 2) {
    return null;
  }
  handshake.decodeServerAll(in);
  Channels.write(ctx, Channels.succeededFuture(channel), handshake.encodeClient2());
  handshakeDone = true;
  rtmpe = handshake.isRtmpe(); // rare chance server refused rtmpe
  if(handshake.getSwfvBytes() != null) {
    ClientHandler clientHandler = channel.getPipeline().get(ClientHandler.class);
    clientHandler.setSwfvBytes(handshake.getSwfvBytes());
  }
  if(!rtmpe) {
    channel.getPipeline().remove(this);
  }
  Channels.fireChannelConnected(ctx, channel.getRemoteAddress());
  return in;
}

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

@Override
protected void connectRequested(ChannelPipeline pipeline, ChannelStateEvent evt) throws Exception {
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("connectRequested pipeline = " + pipeline + " evt = " + evt);
  }
  FileChannel fileChannel = (FileChannel) evt.getChannel();
  ChannelAddress fileAddress = (ChannelAddress) evt.getValue();
  if (!fileChannel.isBound()) {
    fileChannel.setLocalAddress(fileAddress);
    fileChannel.setBound();
    fireChannelBound(fileChannel, fileAddress);
  }
  ChannelFuture connectFuture = evt.getFuture();
  try {
    fileChannel.mapFile();
    connectFuture.setSuccess();
  } catch (Throwable t) {
    connectFuture.setFailure(t);
  }
  fileChannel.setConnected();
  Channels.fireChannelConnected(fileChannel, fileAddress);
  // Send a read event using memory mapped buffer contents so that reads in the
  // scripts can be matched
  fileChannel.fireMessageReceived(fileChannel, fileAddress);
}

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

@Override
  public void operationComplete(ChannelFuture connectFuture) throws Exception {
    if (connectFuture.isSuccess()) {
      transport = connectFuture.getChannel();
      transport.getConfig().setBufferFactory(httpConnectConfig.getBufferFactory());
      ChannelPipeline pipeline = transport.getPipeline();
      ChannelHandlerContext ctx = pipeline.getContext(HttpClientChannelSource.class);
      HttpClientChannelSource channelSource = (HttpClientChannelSource) ctx.getHandler();
      if (!httpConnectChannel.isBound()) {
        ChannelAddress httpLocalAddress = httpRemoteAddress;
        httpConnectChannel.setLocalAddress(httpLocalAddress);
        httpConnectChannel.setBound();
        fireChannelBound(httpConnectChannel, httpLocalAddress);
      }
      channelSource.setHttpChannel(httpConnectChannel);
      httpConnectChannel.setRemoteAddress(httpRemoteAddress);
      httpConnectChannel.setConnected();
      httpConnectFuture.setSuccess();
      fireChannelConnected(httpConnectChannel, httpRemoteAddress);
    } else {
      httpConnectFuture.setFailure(connectFuture.getCause());
    }
  }
});

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

@Override
public void run() {
  serverChannel.setLocalAddress(localAddress);
  serverChannel.setBound();
  fireChannelBound(serverChannel, serverChannel.getLocalAddress());
  try {
    ChannelPipelineFactory pipelineFactory = serverChannel.getConfig().getPipelineFactory();
    ChannelPipeline pipeline = pipelineFactory.getPipeline();
    bindFuture.setSuccess();
    // fire child channel opened
    ChannelFactory channelFactory = serverChannel.getFactory();
    AgronaChildChannelSink channelSink = new AgronaChildChannelSink();
    AgronaChildChannel childChannel =
        new AgronaChildChannel(serverChannel, channelFactory, pipeline, channelSink, serverChannel.worker);
    childChannel.setLocalAddress(serverChannel.getLocalAddress());
    fireChannelBound(childChannel, childChannel.getLocalAddress());
    childChannel.setRemoteAddress(childChannel.getLocalAddress());
    Channels.fireChannelConnected(childChannel, childChannel.getRemoteAddress());
    childChannel.worker.register(childChannel);
  }
  catch (Exception e) {
    bindFuture.setFailure(e);
  }
}

相关文章