本文整理汇总了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();
}
}
}