本文整理匯總了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);
}
}
示例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));
}
示例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();
}
}
}