Class NettyNetworkServer

    • Field Detail

      • channelFutures

        protected final java.util.Map<java.lang.Integer,​de.dytanic.cloudnet.common.collection.Pair<HostAndPort,​io.netty.channel.ChannelFuture>> channelFutures
      • bossEventLoopGroup

        protected final io.netty.channel.EventLoopGroup bossEventLoopGroup
      • workerEventLoopGroup

        protected final io.netty.channel.EventLoopGroup workerEventLoopGroup
      • taskScheduler

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

        protected final boolean taskSchedulerFromConstructor
      • networkChannelHandler

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

        protected io.netty.handler.ssl.SslContext sslContext
    • Constructor Detail

      • NettyNetworkServer

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

        public NettyNetworkServer​(java.util.concurrent.Callable<INetworkChannelHandler> networkChannelHandler,
                                  de.dytanic.cloudnet.common.concurrent.ITaskScheduler taskScheduler)
      • NettyNetworkServer

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

      • isSslEnabled

        public boolean isSslEnabled()
      • addListener

        public boolean addListener​(int port)
        Description copied from interface: INetworkServer
        Binds the server to a specific port with the host alias address "0.0.0.0"
        Specified by:
        addListener in interface INetworkServer
        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: INetworkServer
        Binds the server to a specific address that is as parameter defined
        Specified by:
        addListener in interface INetworkServer
        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:
        close in interface java.lang.AutoCloseable
      • closeChannels

        public void closeChannels()
      • 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
      • init

        protected void init()
                     throws java.lang.Exception
        Throws:
        java.lang.Exception