Class NettyNetworkClient

    • Field Detail

      • eventLoopGroup

        protected final io.netty.channel.EventLoopGroup eventLoopGroup
      • networkChannelHandler

        protected final java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler
      • taskScheduler

        protected final de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler
      • taskSchedulerFromConstructor

        protected final boolean taskSchedulerFromConstructor
      • sslContext

        protected io.netty.handler.ssl.SslContext sslContext
      • connectedTime

        protected long connectedTime
    • Constructor Detail

      • NettyNetworkClient

        public NettyNetworkClient​(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler)
      • NettyNetworkClient

        public NettyNetworkClient​(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler,
                                  SSLConfiguration sslConfiguration,
                                  de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)
    • Method Detail

      • isSslEnabled

        public boolean isSslEnabled()
      • connect

        public boolean connect​(@NotNull
                               @NotNull HostAndPort hostAndPort)
        Description copied from interface: INetworkClient
        Open a new connection to the specific host and port
        Specified by:
        connect in interface INetworkClient
        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:
        close in interface java.lang.AutoCloseable
      • closeChannels

        public void closeChannels()
      • getConnectedTime

        public long getConnectedTime()
        Description copied from interface: INetworkClient
        Gets the time when this client was connected to the server in milliseconds
        Specified by:
        getConnectedTime in interface INetworkClient
      • sendPacket

        public void sendPacket​(@NotNull
                               @NotNull IPacket packet)
        Description copied from interface: IPacketSender
        Transport a packet instance into the network to the receiver. The receiver will handle the packet if he knows the channel and has listeners for the channel

        The packet are doesn't allow to be null

        Specified by:
        sendPacket in interface IPacketSender
        Parameters:
        packet - the packet, which should transport into the network
      • sendPacket

        public void sendPacket​(@NotNull
                               @NotNull IPacket... packets)
        Description copied from interface: IPacketSender
        Transport packet instances into the network to the receiver. The receiver will handle the packets if he knows the channel and has listeners for the channel

        A packet are doesn't allow to be null All elements should be checked that be not null and send after that

        Specified by:
        sendPacket in interface IPacketSender
        Parameters:
        packets - the packets, which should transport into the network