Package org.aesh.terminal.http.netty
Class NettyWebsocketTtyBootstrap
java.lang.Object
org.aesh.terminal.http.netty.NettyWebsocketTtyBootstrap
Convenience class for quickly starting a Netty Tty server.
- Author:
- Julien Viet
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new bootstrap with default host (localhost) and port (8080). -
Method Summary
Modifier and TypeMethodDescriptiongetHost()Returns the host address the server will bind to.intgetPort()Returns the port the server will listen on.Sets the host address for the server to bind to.setPort(int port) Sets the port for the server to listen on.start(Consumer<Connection> handler) Starts the server asynchronously and returns a CompletableFuture.voidstart(Consumer<Connection> handler, Consumer<Throwable> doneHandler) Starts the server asynchronously with callback-based completion notification.stop()Stops the server asynchronously and returns a CompletableFuture.voidStops the server asynchronously with callback-based completion notification.
-
Constructor Details
-
NettyWebsocketTtyBootstrap
public NettyWebsocketTtyBootstrap()Creates a new bootstrap with default host (localhost) and port (8080).
-
-
Method Details
-
getHost
Returns the host address the server will bind to.- Returns:
- the host address
-
setHost
Sets the host address for the server to bind to.- Parameters:
host- the host address- Returns:
- this bootstrap instance for method chaining
-
getPort
public int getPort()Returns the port the server will listen on.- Returns:
- the port number
-
setPort
Sets the port for the server to listen on.- Parameters:
port- the port number- Returns:
- this bootstrap instance for method chaining
-
start
Starts the server asynchronously with callback-based completion notification.- Parameters:
handler- the handler to invoke for each new connectiondoneHandler- the callback invoked when startup completes (with null on success, or the error)
-
start
Starts the server asynchronously and returns a CompletableFuture.- Parameters:
handler- the handler to invoke for each new connection- Returns:
- a CompletableFuture that completes when the server has started
- Throws:
Exception- if an error occurs during startup
-
stop
Stops the server asynchronously with callback-based completion notification.- Parameters:
doneHandler- the callback invoked when shutdown completes
-
stop
Stops the server asynchronously and returns a CompletableFuture.- Returns:
- a CompletableFuture that completes when the server has stopped
- Throws:
InterruptedException- if the thread is interrupted while waiting
-