public final class TcpServer
extends java.lang.Object
| Constructor and Description |
|---|
TcpServer(java.lang.String name)
Create TCP server instance of the given name
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(java.lang.String name,
java.util.function.Supplier<io.netty.channel.ChannelHandler> channelHandler)
Add new named channel handler
|
int |
getBoundToPort()
Get the port this server is bound to
|
void |
onConnect(java.util.function.Supplier<io.netty.channel.ChannelHandler> handler)
Add new connect listener
|
void |
onDisconnect(java.util.function.Supplier<io.netty.channel.ChannelFutureListener> listener)
Add new disconnection listener
|
void |
setBossThreads(int bossThreads)
Set the number of the Netty boss treads
|
void |
setChildOptions(ChannelOptions childOptions)
Set the options for the newly created channels
|
void |
setHost(java.lang.String host)
Set the host the server will listen on
|
void |
setOptions(ChannelOptions options)
Set the options for the acceptor channel
|
void |
setPort(int port)
Set the port the server will listen on
|
void |
setWorkerThreads(int workerThreads)
Set the number of the Netty worker treads
|
public TcpServer(java.lang.String name)
name - Name of the TCP serverpublic int getBoundToPort()
-1 if not boundpublic void setBossThreads(int bossThreads)
bossThreads - Boss thread countpublic void setWorkerThreads(int workerThreads)
workerThreads - Worker thread countpublic void setHost(java.lang.String host)
host - Server hostpublic void setPort(int port)
port - Server portpublic void setOptions(ChannelOptions options)
options - Channel optionspublic void setChildOptions(ChannelOptions childOptions)
childOptions - Channel optionspublic void onDisconnect(java.util.function.Supplier<io.netty.channel.ChannelFutureListener> listener)
listener - Listener to be addedpublic void onConnect(java.util.function.Supplier<io.netty.channel.ChannelHandler> handler)
handler - Listener to be addedpublic void addHandler(java.lang.String name,
java.util.function.Supplier<io.netty.channel.ChannelHandler> channelHandler)
name - Handler namechannelHandler - Handler to be added