當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。