Home / Class/ StreamHandler Class — netty Architecture

StreamHandler Class — netty Architecture

Architecture documentation for the StreamHandler class in QuicStreamFrameTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32["StreamHandler"]
  893fba38_068a_e633_3ac3_b01e62e27f16["QuicStreamFrameTest.java"]
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32 -->|defined in| 893fba38_068a_e633_3ac3_b01e62e27f16
  5e2ce6a1_7588_3854_894c_a388c821fdda["channelRegistered()"]
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32 -->|method| 5e2ce6a1_7588_3854_894c_a388c821fdda
  3393507c_bec5_4ab7_6bf2_81f323d8c8d9["channelInactive()"]
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32 -->|method| 3393507c_bec5_4ab7_6bf2_81f323d8c8d9
  4cd83743_d8d6_77f0_0eb3_a8eadce94339["userEventTriggered()"]
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32 -->|method| 4cd83743_d8d6_77f0_0eb3_a8eadce94339
  a00dcc5b_d54e_5185_5e5e_8bbdd994c07f["channelRead()"]
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32 -->|method| a00dcc5b_d54e_5185_5e5e_8bbdd994c07f
  7be3830e_d641_b8cf_a6de_9ed019419558["assertSequence()"]
  2d2331bc_6e47_3b29_d4ae_abf5f14b8b32 -->|method| 7be3830e_d641_b8cf_a6de_9ed019419558

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamFrameTest.java lines 99–143

    private static final class StreamHandler extends ChannelInboundHandlerAdapter {
        private final BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();

        @Override
        public void channelRegistered(ChannelHandlerContext ctx) {
            ctx.channel().config().setOption(QuicChannelOption.READ_FRAMES, true);
            queue.add(0);
        }

        @Override
        public void channelInactive(ChannelHandlerContext ctx) {
            queue.add(3);
            // Close the QUIC channel as well.
            ctx.channel().parent().close();
        }

        @Override
        public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
            if (evt == ChannelInputShutdownReadComplete.INSTANCE) {
                queue.add(2);
                if (((QuicStreamChannel) ctx.channel()).type() == QuicStreamType.BIDIRECTIONAL) {
                    // Let's write back a fin which will also close the channel and so call channelInactive(...)
                    ctx.writeAndFlush(new DefaultQuicStreamFrame(Unpooled.EMPTY_BUFFER, true));
                }
                ctx.channel().parent().close();
            }
        }

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg) {
            QuicStreamFrame frame = (QuicStreamFrame) msg;
            if (frame.hasFin()) {
                queue.add(1);
            }
            frame.release();
        }

        void assertSequence() throws Exception {
            assertEquals(0, (int) queue.take());
            assertEquals(1, (int) queue.take());
            assertEquals(2, (int) queue.take());
            assertEquals(3, (int) queue.take());
            assertTrue(queue.isEmpty());
        }
    }

Frequently Asked Questions

What is the StreamHandler class?
StreamHandler is a class in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamFrameTest.java.
Where is StreamHandler defined?
StreamHandler is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamFrameTest.java at line 99.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free