Record Class NettyUtil.TimeoutContext

java.lang.Object
java.lang.Record
com.hypixel.hytale.server.core.io.netty.NettyUtil.TimeoutContext
Record Components:
stage - The current stage (e.g., "initial", "auth", "setup:world-settings", "play")
connectionStartNs - The connection start time in nanoseconds (from System.nanoTime())
playerIdentifier - The player identifier (UUID/username if known, or remote address)
Enclosing class:
NettyUtil

public static record NettyUtil.TimeoutContext(@Nonnull String stage, long connectionStartNs, @Nonnull String playerIdentifier) extends Record
Context information for timeout logging, stored as a channel attribute. Tracks the current connection stage, start time, and player identifier for better debugging.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final io.netty.util.AttributeKey<NettyUtil.TimeoutContext>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeoutContext(String stage, long connectionStartNs, String playerIdentifier)
    Creates an instance of a TimeoutContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the connectionStartNs record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    get(io.netty.channel.Channel channel)
    Gets the TimeoutContext from a channel, throwing if not set.
    final int
    Returns a hash code value for this object.
    static void
    init(io.netty.channel.Channel channel, String stage, String identifier)
    Initializes the timeout context for a new connection.
    Returns the value of the playerIdentifier record component.
    Returns the value of the stage record component.
    final String
    Returns a string representation of this record class.
    static void
    update(io.netty.channel.Channel channel, String stage)
    Updates the timeout context with a new stage, keeping the existing identifier.
    static void
    update(io.netty.channel.Channel channel, String stage, String identifier)
    Updates the timeout context with a new stage and identifier.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • TimeoutContext

      public TimeoutContext(@Nonnull String stage, long connectionStartNs, @Nonnull String playerIdentifier)
      Creates an instance of a TimeoutContext record class.
      Parameters:
      stage - the value for the stage record component
      connectionStartNs - the value for the connectionStartNs record component
      playerIdentifier - the value for the playerIdentifier record component
  • Method Details

    • init

      public static void init(@Nonnull io.netty.channel.Channel channel, @Nonnull String stage, @Nonnull String identifier)
      Initializes the timeout context for a new connection. Call this once in InitialPacketHandler.registered0().
      Parameters:
      channel - The channel to set the context on.
      stage - The initial stage name.
      identifier - The player identifier (typically remote address at this point).
    • update

      public static void update(@Nonnull io.netty.channel.Channel channel, @Nonnull String stage, @Nonnull String identifier)
      Updates the timeout context with a new stage and identifier. Preserves the original connection start time.
      Parameters:
      channel - The channel to update.
      stage - The new stage name.
      identifier - The new player identifier.
      Throws:
      IllegalStateException - if the context has not been initialized.
    • update

      public static void update(@Nonnull io.netty.channel.Channel channel, @Nonnull String stage)
      Updates the timeout context with a new stage, keeping the existing identifier. Preserves the original connection start time.
      Parameters:
      channel - The channel to update.
      stage - The new stage name.
      Throws:
      IllegalStateException - if the context has not been initialized.
    • get

      @Nonnull public static NettyUtil.TimeoutContext get(@Nonnull io.netty.channel.Channel channel)
      Gets the TimeoutContext from a channel, throwing if not set.
      Parameters:
      channel - The channel to get the context from.
      Returns:
      The TimeoutContext, never null.
      Throws:
      IllegalStateException - if the context has not been initialized.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • stage

      @Nonnull public String stage()
      Returns the value of the stage record component.
      Returns:
      the value of the stage record component
    • connectionStartNs

      public long connectionStartNs()
      Returns the value of the connectionStartNs record component.
      Returns:
      the value of the connectionStartNs record component
    • playerIdentifier

      @Nonnull public String playerIdentifier()
      Returns the value of the playerIdentifier record component.
      Returns:
      the value of the playerIdentifier record component