Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

Architecture documentation for the decode() function in PortUnificationServerHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6["decode()"]
  0035cd98_439e_cdb1_2619_abb4aba4a268["PortUnificationServerHandler"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|defined in| 0035cd98_439e_cdb1_2619_abb4aba4a268
  8efb1e2d_d4a3_dfe6_6952_9c2c3ed410e3["isSsl()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| 8efb1e2d_d4a3_dfe6_6952_9c2c3ed410e3
  f41ecb92_a386_7e45_1870_e2126e8202ac["enableSsl()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| f41ecb92_a386_7e45_1870_e2126e8202ac
  c115e1be_c004_4723_1d8d_ff6eac5b5eca["isGzip()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| c115e1be_c004_4723_1d8d_ff6eac5b5eca
  48a9eded_6f9c_3cad_72d3_82ff38ffecf1["enableGzip()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| 48a9eded_6f9c_3cad_72d3_82ff38ffecf1
  54693d02_409a_0835_0870_dca0e376bca9["isHttp()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| 54693d02_409a_0835_0870_dca0e376bca9
  640d12e2_2b98_1048_fac3_cf3977c9655d["switchToHttp()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| 640d12e2_2b98_1048_fac3_cf3977c9655d
  99396a68_6df1_d1c5_cc6c_1872bdcc9221["isFactorial()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| 99396a68_6df1_d1c5_cc6c_1872bdcc9221
  20fe5679_2b0a_75ac_82c8_fa37abbd573d["switchToFactorial()"]
  46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 -->|calls| 20fe5679_2b0a_75ac_82c8_fa37abbd573d
  style 46a8a557_e9f2_75bd_144b_c3fb8b8fd5d6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/portunification/PortUnificationServerHandler.java lines 59–83

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        // Will use the first five bytes to detect a protocol.
        if (in.readableBytes() < 5) {
            return;
        }

        if (isSsl(in)) {
            enableSsl(ctx);
        } else {
            final int magic1 = in.getUnsignedByte(in.readerIndex());
            final int magic2 = in.getUnsignedByte(in.readerIndex() + 1);
            if (isGzip(magic1, magic2)) {
                enableGzip(ctx);
            } else if (isHttp(magic1, magic2)) {
                switchToHttp(ctx);
            } else if (isFactorial(magic1)) {
                switchToFactorial(ctx);
            } else {
                // Unknown protocol; discard everything and close the connection.
                in.clear();
                ctx.close();
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does decode() do?
decode() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/portunification/PortUnificationServerHandler.java.
Where is decode() defined?
decode() is defined in example/src/main/java/io/netty/example/portunification/PortUnificationServerHandler.java at line 59.
What does decode() call?
decode() calls 8 function(s): enableGzip, enableSsl, isFactorial, isGzip, isHttp, isSsl, switchToFactorial, switchToHttp.

Analyze Your Own Codebase

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

Try Supermodel Free