Home / Class/ SecureChatClient Class — netty Architecture

SecureChatClient Class — netty Architecture

Architecture documentation for the SecureChatClient class in SecureChatClient.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a1916538_6ef5_559d_d946_3a8030dd0b48["SecureChatClient"]
  2251f6f3_29af_9519_0e5e_99232ec6082c["SecureChatClient.java"]
  a1916538_6ef5_559d_d946_3a8030dd0b48 -->|defined in| 2251f6f3_29af_9519_0e5e_99232ec6082c
  d2fc83e2_2b30_ddf5_28f9_353ddedc2a7d["main()"]
  a1916538_6ef5_559d_d946_3a8030dd0b48 -->|method| d2fc83e2_2b30_ddf5_28f9_353ddedc2a7d

Relationship Graph

Source Code

example/src/main/java/io/netty/example/securechat/SecureChatClient.java lines 36–85

public final class SecureChatClient {

    static final String HOST = System.getProperty("host", "127.0.0.1");
    static final int PORT = Integer.parseInt(System.getProperty("port", "8992"));

    public static void main(String[] args) throws Exception {
        // Configure SSL.
        final SslContext sslCtx = SslContextBuilder.forClient()
            .trustManager(InsecureTrustManagerFactory.INSTANCE).build();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            Bootstrap b = new Bootstrap();
            b.group(group)
             .channel(NioSocketChannel.class)
             .handler(new SecureChatClientInitializer(sslCtx));

            // Start the connection attempt.
            Channel ch = b.connect(HOST, PORT).sync().channel();

            // Read commands from the stdin.
            ChannelFuture lastWriteFuture = null;
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            for (;;) {
                String line = in.readLine();
                if (line == null) {
                    break;
                }

                // Sends the received line to the server.
                lastWriteFuture = ch.writeAndFlush(line + "\r\n");

                // If user typed the 'bye' command, wait until the server closes
                // the connection.
                if ("bye".equals(line.toLowerCase())) {
                    ch.closeFuture().sync();
                    break;
                }
            }

            // Wait until all messages are flushed before closing the channel.
            if (lastWriteFuture != null) {
                lastWriteFuture.sync();
            }
        } finally {
            // The connection is closed automatically on shutdown.
            group.shutdownGracefully();
        }
    }
}

Frequently Asked Questions

What is the SecureChatClient class?
SecureChatClient is a class in the netty codebase, defined in example/src/main/java/io/netty/example/securechat/SecureChatClient.java.
Where is SecureChatClient defined?
SecureChatClient is defined in example/src/main/java/io/netty/example/securechat/SecureChatClient.java at line 36.

Analyze Your Own Codebase

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

Try Supermodel Free