Home / Function/ main() — netty Function Reference

main() — netty Function Reference

Architecture documentation for the main() function in MqttHeartBeatClient.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  e515ec07_5d83_ce86_70de_5827b66d6ffe["main()"]
  1d714412_cfc4_8964_f87b_258c0bb6af25["MqttHeartBeatClient"]
  e515ec07_5d83_ce86_70de_5827b66d6ffe -->|defined in| 1d714412_cfc4_8964_f87b_258c0bb6af25
  style e515ec07_5d83_ce86_70de_5827b66d6ffe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/mqtt/heartBeat/MqttHeartBeatClient.java lines 42–65

    public static void main(String[] args) throws Exception {
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());

        try {
            Bootstrap b = new Bootstrap();
            b.group(group);
            b.channel(NioSocketChannel.class);
            b.handler(new ChannelInitializer<SocketChannel>() {
                @Override
                protected void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast("encoder", MqttEncoder.INSTANCE);
                    ch.pipeline().addLast("decoder", new MqttDecoder());
                    ch.pipeline().addLast("heartBeatHandler", new IdleStateHandler(0, 20, 0, TimeUnit.SECONDS));
                    ch.pipeline().addLast("handler", new MqttHeartBeatClientHandler(CLIENT_ID, USER_NAME, PASSWORD));
                }
            });

            ChannelFuture f = b.connect(HOST, PORT).sync();
            System.out.println("Client connected");
            f.channel().closeFuture().sync();
        } finally {
            group.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/mqtt/heartBeat/MqttHeartBeatClient.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/mqtt/heartBeat/MqttHeartBeatClient.java at line 42.

Analyze Your Own Codebase

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

Try Supermodel Free