QuicClientZeroRTTExample Class — netty Architecture
Architecture documentation for the QuicClientZeroRTTExample class in QuicClientZeroRTTExample.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 40abcc0a_1b6f_95df_e40b_99a4345531f2["QuicClientZeroRTTExample"] 75bf757b_c0b5_deba_4e27_0ff1fa5dd4cd["QuicClientZeroRTTExample.java"] 40abcc0a_1b6f_95df_e40b_99a4345531f2 -->|defined in| 75bf757b_c0b5_deba_4e27_0ff1fa5dd4cd 03416acd_be01_aef4_0732_355ebed84934["QuicClientZeroRTTExample()"] 40abcc0a_1b6f_95df_e40b_99a4345531f2 -->|method| 03416acd_be01_aef4_0732_355ebed84934 860d8561_a1bb_23ff_6c07_2e9bea82ddbc["main()"] 40abcc0a_1b6f_95df_e40b_99a4345531f2 -->|method| 860d8561_a1bb_23ff_6c07_2e9bea82ddbc 0b50309a_9360_0fb3_1b8d_1c4a3d1ac0ab["newChannelAndSendData()"] 40abcc0a_1b6f_95df_e40b_99a4345531f2 -->|method| 0b50309a_9360_0fb3_1b8d_1c4a3d1ac0ab f2361233_d807_e21f_32f0_2702a50cf848["createStream()"] 40abcc0a_1b6f_95df_e40b_99a4345531f2 -->|method| f2361233_d807_e21f_32f0_2702a50cf848
Relationship Graph
Source Code
codec-native-quic/src/test/java/io/netty/handler/codec/quic/example/QuicClientZeroRTTExample.java lines 46–143
public final class QuicClientZeroRTTExample {
private QuicClientZeroRTTExample() { }
public static void main(String[] args) throws Exception {
QuicSslContext context = QuicSslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).
applicationProtocols("http/0.9").earlyData(true).build();
newChannelAndSendData(context, null);
newChannelAndSendData(context, new ChannelInboundHandlerAdapter() {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof SslEarlyDataReadyEvent) {
createStream((QuicChannel) ctx.channel()).addListener(f -> {
if (f.isSuccess()) {
QuicStreamChannel streamChannel = (QuicStreamChannel) f.getNow();
streamChannel.writeAndFlush(
Unpooled.copiedBuffer("0rtt stream data\r\n", CharsetUtil.US_ASCII));
}
});
}
super.userEventTriggered(ctx, evt);
}
});
}
static void newChannelAndSendData(QuicSslContext context, ChannelHandler earlyDataSendHandler) throws Exception {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
try {
ChannelHandler codec = new QuicClientCodecBuilder()
.sslEngineProvider(q -> context.newEngine(q.alloc(), "localhost", 9999))
.maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
.initialMaxData(10000000)
// As we don't want to support remote initiated streams just setup the limit for local initiated
// streams in this example.
.initialMaxStreamDataBidirectionalLocal(1000000)
.build();
Bootstrap bs = new Bootstrap();
Channel channel = bs.group(group)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(0).sync().channel();
QuicChannelBootstrap quicChannelBootstrap = QuicChannel.newBootstrap(channel)
.streamHandler(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
// As we did not allow any remote initiated streams we will never see this method called.
// That said just let us keep it here to demonstrate that this handle would be called
// for each remote initiated stream.
ctx.close();
}
})
.remoteAddress(new InetSocketAddress(NetUtil.LOCALHOST4, 9999));
if (earlyDataSendHandler != null) {
quicChannelBootstrap.handler(earlyDataSendHandler);
}
QuicChannel quicChannel = quicChannelBootstrap
.connect()
.get();
QuicStreamChannel streamChannel = createStream(quicChannel).sync().getNow();
// Write the data and send the FIN. After this its not possible anymore to write any more data.
streamChannel.writeAndFlush(Unpooled.copiedBuffer("Bye\r\n", CharsetUtil.US_ASCII))
.addListener(QuicStreamChannel.SHUTDOWN_OUTPUT);
streamChannel.closeFuture().sync();
quicChannel.closeFuture().sync();
channel.close().sync();
} finally {
group.shutdownGracefully();
}
}
static Future<QuicStreamChannel> createStream(QuicChannel quicChannel) {
return quicChannel.createStream(QuicStreamType.BIDIRECTIONAL,
new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
Defined In
Source
Frequently Asked Questions
What is the QuicClientZeroRTTExample class?
QuicClientZeroRTTExample is a class in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/example/QuicClientZeroRTTExample.java.
Where is QuicClientZeroRTTExample defined?
QuicClientZeroRTTExample is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/example/QuicClientZeroRTTExample.java at line 46.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free