Class NettyNetworkClient
- java.lang.Object
-
- de.dytanic.cloudnet.driver.network.netty.client.NettyNetworkClient
-
- All Implemented Interfaces:
DefaultNetworkComponent,INetworkClient,IPacketSender,java.lang.AutoCloseable
@Internal public final class NettyNetworkClient extends java.lang.Object implements DefaultNetworkComponent, INetworkClient
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Collection<INetworkChannel>channelsprotected longconnectedTimeprotected io.netty.channel.EventLoopGroupeventLoopGroupprotected java.util.concurrent.Callable<INetworkChannelHandler>networkChannelHandlerprotected java.util.concurrent.ExecutorpacketDispatcherprotected IPacketListenerRegistrypacketRegistryprotected SSLConfigurationsslConfigurationprotected io.netty.handler.ssl.SslContextsslContext
-
Constructor Summary
Constructors Constructor Description NettyNetworkClient(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)NettyNetworkClient(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, SSLConfiguration sslConfiguration)NettyNetworkClient(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 voidclose()booleanconnect(@NotNull HostAndPort hostAndPort)Open a new connection to the specific host and portjava.util.Collection<INetworkChannel>getChannels()longgetConnectedTime()Gets the time when this client was connected to the server in millisecondsdefault INetworkChannelgetFirstChannel()java.util.Collection<INetworkChannel>getModifiableChannels()java.util.concurrent.ExecutorgetPacketDispatcher()IPacketListenerRegistrygetPacketRegistry()booleanisSslEnabled()-
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
-
Methods inherited from interface de.dytanic.cloudnet.driver.network.protocol.IPacketSender
sendPacketSync
-
-
-
-
Field Detail
-
packetDispatcher
protected final java.util.concurrent.Executor packetDispatcher
-
eventLoopGroup
protected final io.netty.channel.EventLoopGroup eventLoopGroup
-
channels
protected final java.util.Collection<INetworkChannel> channels
-
packetRegistry
protected final IPacketListenerRegistry packetRegistry
-
networkChannelHandler
protected final java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler
-
sslConfiguration
protected final SSLConfiguration sslConfiguration
-
connectedTime
protected long connectedTime
-
sslContext
protected io.netty.handler.ssl.SslContext sslContext
-
-
Constructor Detail
-
NettyNetworkClient
public NettyNetworkClient(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)
-
NettyNetworkClient
public NettyNetworkClient(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, SSLConfiguration sslConfiguration)
-
NettyNetworkClient
@Deprecated @ScheduledForRemoval public NettyNetworkClient(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler, SSLConfiguration sslConfiguration, de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)
Deprecated.
-
-
Method Detail
-
isSslEnabled
public boolean isSslEnabled()
-
connect
public boolean connect(@NotNull @NotNull HostAndPort hostAndPort)Description copied from interface:INetworkClientOpen a new connection to the specific host and port- Specified by:
connectin interfaceINetworkClient- Parameters:
hostAndPort- the address, that should the client connect to- Returns:
- true if the connection was success or false if the connection was unsuccessful or refused
-
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
-
getConnectedTime
public long getConnectedTime()
Description copied from interface:INetworkClientGets the time when this client was connected to the server in milliseconds- Specified by:
getConnectedTimein interfaceINetworkClient
-
getPacketRegistry
public IPacketListenerRegistry getPacketRegistry()
-
getFirstChannel
public default INetworkChannel getFirstChannel()
-
-