当前位置: 首页>>代码示例>>Java>>正文


Java ChannelPipeline.addBefore方法代码示例

本文整理汇总了Java中io.netty.channel.ChannelPipeline.addBefore方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelPipeline.addBefore方法的具体用法?Java ChannelPipeline.addBefore怎么用?Java ChannelPipeline.addBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.ChannelPipeline的用法示例。


在下文中一共展示了ChannelPipeline.addBefore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initiateProtocolOrSsl

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
void initiateProtocolOrSsl(String username, String password, String database, Handler<? super CommandResponse<Connection>> completionHandler) {
  ChannelPipeline pipeline = socket.channelHandlerContext().pipeline();
  if (ssl) {
    Future<Void> upgradeFuture = Future.future();
    upgradeFuture.setHandler(ar -> {
      if (ar.succeeded()) {
        initiateProtocol(username, password, database, completionHandler);
      } else {
        Throwable cause = ar.cause();
        if (cause instanceof DecoderException) {
          DecoderException err = (DecoderException) cause;
          cause = err.getCause();
        }
        completionHandler.handle(CommandResponse.failure(cause));
      }
    });
    pipeline.addBefore("handler", "initiate-ssl-handler", new InitiateSslHandler(this, upgradeFuture));
  } else {
    initiateProtocol(username, password, database, completionHandler);
  }
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:22,代码来源:SocketConnection.java

示例2: initiateProtocol

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
private void initiateProtocol(String username, String password, String database, Handler<? super CommandResponse<Connection>> completionHandler) {
  ChannelPipeline pipeline = socket.channelHandlerContext().pipeline();
  pipeline.addBefore("handler", "decoder", new MessageDecoder(decodeQueue));
  socket.closeHandler(this::handleClosed);
  socket.exceptionHandler(this::handleException);
  socket.messageHandler(this::handleMessage);
  schedule(new InitCommand(username, password, database, completionHandler));
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:9,代码来源:SocketConnection.java

示例3: startProtocolEncryption

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
public void startProtocolEncryption( SecretKey key ) {
    if ( this.encrypted.compareAndSet( false, true ) ) {

        ChannelPipeline pipeline = this.channelHandlerContext.channel().pipeline();
        try {
            pipeline.addBefore( "splitter", "decrypter", new MessageDecrypter( AuthHelper.createCipher( false, key ) ) );
            pipeline.addBefore( "prepender", "encrypter", new MessageEncrypter( AuthHelper.createCipher( true, key ) ) );
        } catch ( NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | InvalidAlgorithmParameterException e ) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:13,代码来源:ConnectionHandler.java


注:本文中的io.netty.channel.ChannelPipeline.addBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。