Class NettyUtil

java.lang.Object
com.hypixel.hytale.server.core.io.netty.NettyUtil

public class NettyUtil extends Object
  • Field Details

    • CONNECTION_EXCEPTION_LOGGER

      public static final HytaleLogger CONNECTION_EXCEPTION_LOGGER
    • PACKET_LOGGER

      public static final HytaleLogger PACKET_LOGGER
    • PACKET_DECODER

      public static final String PACKET_DECODER
      See Also:
    • PACKET_ARRAY_ENCODER

      public static final String PACKET_ARRAY_ENCODER
      See Also:
    • PACKET_ARRAY_ENCODER_INSTANCE

      public static final PacketArrayEncoder PACKET_ARRAY_ENCODER_INSTANCE
    • PACKET_ENCODER

      public static final String PACKET_ENCODER
      See Also:
    • LOGGER_KEY

      public static final String LOGGER_KEY
      See Also:
    • LOGGER

      public static final io.netty.handler.logging.LoggingHandler LOGGER
    • HANDLER

      public static final String HANDLER
      See Also:
    • RATE_LIMIT

      public static final String RATE_LIMIT
      See Also:
    • CLOSE_ON_COMPLETE

      public static final io.netty.channel.ChannelFutureListener CLOSE_ON_COMPLETE
      A ChannelFutureListener that closes the connection gracefully after a write completes.
  • Constructor Details

    • NettyUtil

      public NettyUtil()
  • Method Details

    • init

      public static void init()
    • closeConnection

      public static void closeConnection(@Nonnull io.netty.channel.Channel channel)
      Closes a raw Netty channel due to a transport-level protocol violation. For use in Netty pipeline handlers that operate on raw Channel objects.
    • closeApplicationConnection

      public static void closeApplicationConnection(@Nonnull io.netty.channel.Channel channel)
      Closes a raw Netty channel gracefully with an application error code. For use in Netty pipeline handlers that operate on raw Channel objects.
    • closeApplicationConnection

      public static void closeApplicationConnection(@Nonnull io.netty.channel.Channel channel, @Nonnull QuicApplicationErrorCode errorCode)
      Closes a raw Netty channel gracefully with a specific application error code. For use in Netty pipeline handlers that operate on raw Channel objects.
    • closeApplicationConnection

      public static void closeApplicationConnection(@Nonnull io.netty.channel.Channel channel, @Nonnull QuicApplicationErrorCode errorCode, @Nonnull FormattedMessage reason)
      Closes a raw Netty channel gracefully with an application error code and a FormattedMessage serialized into the QUIC CONNECTION_CLOSE reason phrase. Falls back to a reason-less close if the encoded message exceeds the datagram-safe cap.
    • getEventLoopGroup

      @Nonnull public static io.netty.channel.EventLoopGroup getEventLoopGroup(String name)
    • getEventLoopGroup

      @Nonnull public static io.netty.channel.EventLoopGroup getEventLoopGroup(int nThreads, String name)
    • getServerChannel

      @Nonnull public static Class<? extends io.netty.channel.ServerChannel> getServerChannel()
    • getDatagramChannelFactory

      @Nonnull public static NettyUtil.ReflectiveChannelFactory<? extends io.netty.channel.socket.DatagramChannel> getDatagramChannelFactory(io.netty.channel.socket.SocketProtocolFamily family)
    • formatRemoteAddress

      public static String formatRemoteAddress(io.netty.channel.Channel channel)
    • formatLocalAddress

      public static String formatLocalAddress(io.netty.channel.Channel channel)
    • getRemoteSocketAddress

      @Nullable public static SocketAddress getRemoteSocketAddress(io.netty.channel.Channel channel)
    • isFromSameOrigin

      public static boolean isFromSameOrigin(io.netty.channel.Channel channel1, io.netty.channel.Channel channel2)
      Tests if the two netty channels are from the same origin address. See ConnectionOrigin.isFromSameOrigin(SocketAddress, SocketAddress) for the comparison rules.
      Parameters:
      channel1 - The first channel
      channel2 - The second channel
      Returns:
      true if they are from the same "origin"
    • wrapChannelFuture

      @Nonnull public static <T> CompletableFuture<T> wrapChannelFuture(@Nonnull io.netty.channel.ChannelFuture future, @Nonnull Function<io.netty.channel.ChannelFuture, T> func)