Class NettyNetworkServer
- java.lang.Object
-
- de.dytanic.cloudnet.driver.network.netty.NettySSLServer
-
- de.dytanic.cloudnet.driver.network.netty.server.NettyNetworkServer
-
- All Implemented Interfaces:
DefaultNetworkComponent,INetworkServer,IPacketSender,java.lang.AutoCloseable
@Internal public final class NettyNetworkServer extends NettySSLServer implements DefaultNetworkComponent, INetworkServer
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty.channel.EventLoopGroupbossEventLoopGroupprotected java.util.Map<java.lang.Integer,de.dytanic.cloudnet.common.collection.Pair<HostAndPort,io.netty.channel.ChannelFuture>>channelFuturesprotected java.util.Collection<INetworkChannel>channelsprotected java.util.concurrent.Callable<INetworkChannelHandler>networkChannelHandlerprotected java.util.concurrent.ExecutorpacketDispatcherprotected IPacketListenerRegistrypacketRegistryprotected io.netty.channel.EventLoopGroupworkerEventLoopGroup-
Fields inherited from class de.dytanic.cloudnet.driver.network.netty.NettySSLServer
sslConfiguration, sslContext
-
-
Constructor Summary
Constructors Constructor Description NettyNetworkServer(SSLConfiguration sslConfiguration, java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)NettyNetworkServer(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)NettyNetworkServer(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)Deprecated.NettyNetworkServer(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, SSLConfiguration sslConfiguration, de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Default Methods Modifier and Type Method Description booleanaddListener(int port)Binds the server to a specific port with the host alias address "0.0.0.0"booleanaddListener(@NotNull HostAndPort hostAndPort)Binds the server to a specific address that is as parameter definedvoidclose()java.util.Collection<INetworkChannel>getChannels()default INetworkChannelgetFirstChannel()java.util.Collection<INetworkChannel>getModifiableChannels()java.util.concurrent.ExecutorgetPacketDispatcher()IPacketListenerRegistrygetPacketRegistry()booleanisSslEnabled()voidsendPacketSync(@NotNull IPacket... packets)Transport packet instances into the network to the receiver synchronously.-
Methods inherited from class de.dytanic.cloudnet.driver.network.netty.NettySSLServer
init
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.dytanic.cloudnet.driver.network.DefaultNetworkComponent
closeChannels, sendPacket, sendPacket, sendPacketSync
-
-
-
-
Field Detail
-
channels
protected final java.util.Collection<INetworkChannel> channels
-
channelFutures
protected final java.util.Map<java.lang.Integer,de.dytanic.cloudnet.common.collection.Pair<HostAndPort,io.netty.channel.ChannelFuture>> channelFutures
-
packetRegistry
protected final IPacketListenerRegistry packetRegistry
-
packetDispatcher
protected final java.util.concurrent.Executor packetDispatcher
-
bossEventLoopGroup
protected final io.netty.channel.EventLoopGroup bossEventLoopGroup
-
workerEventLoopGroup
protected final io.netty.channel.EventLoopGroup workerEventLoopGroup
-
networkChannelHandler
protected final java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler
-
-
Constructor Detail
-
NettyNetworkServer
public NettyNetworkServer(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)
-
NettyNetworkServer
public NettyNetworkServer(SSLConfiguration sslConfiguration, java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)
-
NettyNetworkServer
@Deprecated public NettyNetworkServer(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)
Deprecated.
-
NettyNetworkServer
@Deprecated public NettyNetworkServer(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, SSLConfiguration sslConfiguration, de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)
Deprecated.
-
-
Method Detail
-
isSslEnabled
public boolean isSslEnabled()
-
addListener
public boolean addListener(int port)
Description copied from interface:INetworkServerBinds the server to a specific port with the host alias address "0.0.0.0"- Specified by:
addListenerin interfaceINetworkServer- Parameters:
port- the port, that the server should bind- Returns:
- true when the binding was successful or false if an error was threw or the port is already bind
-
addListener
public boolean addListener(@NotNull @NotNull HostAndPort hostAndPort)Description copied from interface:INetworkServerBinds the server to a specific address that is as parameter defined- Specified by:
addListenerin interfaceINetworkServer- Parameters:
hostAndPort- the address that should the server bind- Returns:
- true when the binding was successful or false if an error was threw or the port is already bind
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
getChannels
public java.util.Collection<INetworkChannel> getChannels()
-
getPacketDispatcher
public java.util.concurrent.Executor getPacketDispatcher()
-
getModifiableChannels
public java.util.Collection<INetworkChannel> getModifiableChannels()
- Specified by:
getModifiableChannelsin interfaceDefaultNetworkComponent
-
sendPacketSync
public void sendPacketSync(@NotNull @NotNull IPacket... packets)Description copied from interface:IPacketSenderTransport packet instances into the network to the receiver synchronously. The receiver will handle the packets if he knows the channel and has listeners for the channelA packet are doesn't allow to be null All elements should be checked that be not null and send after that
- Specified by:
sendPacketSyncin interfaceIPacketSender- Parameters:
packets- the packets, which should transport into the network
-
getPacketRegistry
public IPacketListenerRegistry getPacketRegistry()
-
getFirstChannel
public default INetworkChannel getFirstChannel()
-
-