QuicServerZeroRTTExample Class — netty Architecture
Architecture documentation for the QuicServerZeroRTTExample class in QuicServerZeroRTTExample.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 44143fe5_99ab_46f8_a966_b3ef5bf1cb2f["QuicServerZeroRTTExample"] f3a6bd0e_355d_ee10_f199_eecce5b7cc14["QuicServerZeroRTTExample.java"] 44143fe5_99ab_46f8_a966_b3ef5bf1cb2f -->|defined in| f3a6bd0e_355d_ee10_f199_eecce5b7cc14 52dca6af_3a28_f410_37ec_86cf4b6befa8["QuicServerZeroRTTExample()"] 44143fe5_99ab_46f8_a966_b3ef5bf1cb2f -->|method| 52dca6af_3a28_f410_37ec_86cf4b6befa8 a99d8b78_3eaf_a873_87e0_42d6fead5198["main()"] 44143fe5_99ab_46f8_a966_b3ef5bf1cb2f -->|method| a99d8b78_3eaf_a873_87e0_42d6fead5198
Relationship Graph
Source Code
codec-native-quic/src/test/java/io/netty/handler/codec/quic/example/QuicServerZeroRTTExample.java lines 43–122
public final class QuicServerZeroRTTExample {
private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(QuicServerZeroRTTExample.class);
private QuicServerZeroRTTExample() { }
public static void main(String[] args) throws Exception {
SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate();
QuicSslContext context = QuicSslContextBuilder.forServer(
selfSignedCertificate.privateKey(), null, selfSignedCertificate.certificate())
.applicationProtocols("http/0.9").earlyData(true).build();
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
ChannelHandler codec = new QuicServerCodecBuilder().sslContext(context)
.maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
// Configure some limits for the maximal number of streams (and the data) that we want to handle.
.initialMaxData(10000000)
.initialMaxStreamDataBidirectionalLocal(1000000)
.initialMaxStreamDataBidirectionalRemote(1000000)
.initialMaxStreamsBidirectional(100)
.initialMaxStreamsUnidirectional(100)
// Disable token usage. In a production system you would want to implement and provide your custom
// one.
.tokenHandler(null)
// ChannelHandler that is added into QuicChannel pipeline.
.handler(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
QuicChannel channel = (QuicChannel) ctx.channel();
// Create streams etc..
}
public void channelInactive(ChannelHandlerContext ctx) {
((QuicChannel) ctx.channel()).collectStats().addListener(f -> {
if (f.isSuccess()) {
LOGGER.info("Connection closed: {}", f.getNow());
}
});
}
@Override
public boolean isSharable() {
return true;
}
})
.streamHandler(new ChannelInitializer<QuicStreamChannel>() {
@Override
protected void initChannel(QuicStreamChannel ch) {
// Add a LineBasedFrameDecoder here as we just want to do some simple HTTP 0.9 handling.
ch.pipeline().addLast(new LineBasedFrameDecoder(1024))
.addLast(new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ByteBuf byteBuf = (ByteBuf) msg;
try {
if (byteBuf.toString(CharsetUtil.US_ASCII).trim().equals("Bye")) {
ByteBuf buffer = ctx.alloc().directBuffer();
buffer.writeCharSequence("Bye\r\n", CharsetUtil.US_ASCII);
// Write the buffer and shutdown the output by writing a FIN.
ctx.writeAndFlush(buffer).addListener(QuicStreamChannel.SHUTDOWN_OUTPUT);
}
} finally {
byteBuf.release();
}
}
});
}
}).build();
try {
Bootstrap bs = new Bootstrap();
Channel channel = bs.group(group)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(new InetSocketAddress(9999)).sync().channel();
channel.closeFuture().sync();
} finally {
group.shutdownGracefully();
}
}
}
Defined In
Source
Frequently Asked Questions
What is the QuicServerZeroRTTExample class?
QuicServerZeroRTTExample is a class in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/example/QuicServerZeroRTTExample.java.
Where is QuicServerZeroRTTExample defined?
QuicServerZeroRTTExample is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/example/QuicServerZeroRTTExample.java at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free