Class NetworkManager

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
    Direct Known Subclasses:
    RateLimitedNetworkManager

    public class NetworkManager
    extends io.netty.channel.SimpleChannelInboundHandler<IPacket<?>>
    • Field Detail

      • LOGGER

        private static final org.apache.logging.log4j.Logger LOGGER
      • ROOT_MARKER

        public static final org.apache.logging.log4j.Marker ROOT_MARKER
      • PACKET_MARKER

        public static final org.apache.logging.log4j.Marker PACKET_MARKER
      • ATTRIBUTE_PROTOCOL

        public static final io.netty.util.AttributeKey<ProtocolType> ATTRIBUTE_PROTOCOL
      • NETWORK_WORKER_GROUP

        public static final LazyValue<io.netty.channel.nio.NioEventLoopGroup> NETWORK_WORKER_GROUP
      • NETWORK_EPOLL_WORKER_GROUP

        public static final LazyValue<io.netty.channel.epoll.EpollEventLoopGroup> NETWORK_EPOLL_WORKER_GROUP
      • LOCAL_WORKER_GROUP

        public static final LazyValue<io.netty.channel.DefaultEventLoopGroup> LOCAL_WORKER_GROUP
      • channel

        private io.netty.channel.Channel channel
      • address

        private java.net.SocketAddress address
      • encrypted

        private boolean encrypted
      • disconnectionHandled

        private boolean disconnectionHandled
      • receivedPackets

        private int receivedPackets
      • sentPackets

        private int sentPackets
      • averageReceivedPackets

        private float averageReceivedPackets
      • averageSentPackets

        private float averageSentPackets
      • tickCount

        private int tickCount
      • handlingFault

        private boolean handlingFault
      • activationHandler

        private java.util.function.Consumer<NetworkManager> activationHandler
    • Constructor Detail

    • Method Detail

      • channelActive

        public void channelActive​(io.netty.channel.ChannelHandlerContext p_channelActive_1_)
                           throws java.lang.Exception
        Specified by:
        channelActive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • setProtocol

        public void setProtocol​(ProtocolType p_150723_1_)
      • channelInactive

        public void channelInactive​(io.netty.channel.ChannelHandlerContext p_channelInactive_1_)
                             throws java.lang.Exception
        Specified by:
        channelInactive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext p_exceptionCaught_1_,
                                    java.lang.Throwable p_exceptionCaught_2_)
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      • channelRead0

        protected void channelRead0​(io.netty.channel.ChannelHandlerContext p_channelRead0_1_,
                                    IPacket<?> p_channelRead0_2_)
                             throws java.lang.Exception
        Specified by:
        channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<IPacket<?>>
        Throws:
        java.lang.Exception
      • setListener

        public void setListener​(INetHandler p_150719_1_)
      • send

        public void send​(IPacket<?> p_179290_1_)
      • send

        public void send​(IPacket<?> p_201058_1_,
                         @Nullable
                         io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> p_201058_2_)
      • sendPacket

        private void sendPacket​(IPacket<?> p_150732_1_,
                                @Nullable
                                io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> p_150732_2_)
      • flushQueue

        private void flushQueue()
      • tick

        public void tick()
      • tickSecond

        protected void tickSecond()
      • getRemoteAddress

        public java.net.SocketAddress getRemoteAddress()
      • isMemoryConnection

        public boolean isMemoryConnection()
      • connectToServer

        public static NetworkManager connectToServer​(java.net.InetAddress p_181124_0_,
                                                     int p_181124_1_,
                                                     boolean p_181124_2_)
      • connectToLocalServer

        public static NetworkManager connectToLocalServer​(java.net.SocketAddress p_150722_0_)
      • setEncryptionKey

        public void setEncryptionKey​(javax.crypto.Cipher p_244777_1_,
                                     javax.crypto.Cipher p_244777_2_)
      • isEncrypted

        public boolean isEncrypted()
      • isConnected

        public boolean isConnected()
      • isConnecting

        public boolean isConnecting()
      • getPacketListener

        public INetHandler getPacketListener()
      • getDisconnectedReason

        @Nullable
        public ITextComponent getDisconnectedReason()
      • setReadOnly

        public void setReadOnly()
      • setupCompression

        public void setupCompression​(int p_179289_1_)
      • handleDisconnection

        public void handleDisconnection()
      • getAverageReceivedPackets

        public float getAverageReceivedPackets()
      • getAverageSentPackets

        public float getAverageSentPackets()
      • channel

        public io.netty.channel.Channel channel()