Home / Function/ main() — netty Function Reference

main() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  972c152f_5e56_d101_8b6a_25d3214e650f["main()"]
  a92e1647_c16d_4906_57e3_56ea7e4ca686["MqttHeartBeatBroker"]
  972c152f_5e56_d101_8b6a_25d3214e650f -->|defined in| a92e1647_c16d_4906_57e3_56ea7e4ca686
  style 972c152f_5e56_d101_8b6a_25d3214e650f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/mqtt/heartBeat/MqttHeartBeatBroker.java lines 38–63

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

        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(group);
            b.option(ChannelOption.SO_BACKLOG, 1024);
            b.channel(NioServerSocketChannel.class);
            b.childHandler(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(45, 0, 0, TimeUnit.SECONDS));
                    ch.pipeline().addLast("handler", MqttHeartBeatBrokerHandler.INSTANCE);
                }
            });

            ChannelFuture f = b.bind(1883).sync();
            System.out.println("Broker initiated...");

            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/MqttHeartBeatBroker.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/mqtt/heartBeat/MqttHeartBeatBroker.java at line 38.

Analyze Your Own Codebase

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

Try Supermodel Free