Contents
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
FieldsModifier and TypeFieldDescriptionstatic final io.netty.util.AttributeKey<NettyUtil.TimeoutContext> -
Constructor Summary
ConstructorsConstructorDescriptionTimeoutContext(String stage, long connectionStartNs, String playerIdentifier) Creates an instance of aTimeoutContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of theconnectionStartNsrecord component.final booleanIndicates whether some other object is "equal to" this one.static NettyUtil.TimeoutContextget(io.netty.channel.Channel channel) Gets the TimeoutContext from a channel, throwing if not set.final inthashCode()Returns a hash code value for this object.static voidInitializes the timeout context for a new connection.Returns the value of theplayerIdentifierrecord component.stage()Returns the value of thestagerecord component.final StringtoString()Returns a string representation of this record class.static voidUpdates the timeout context with a new stage, keeping the existing identifier.static voidUpdates the timeout context with a new stage and identifier.
-
Field Details
-
KEY
-
-
Constructor Details
-
TimeoutContext
public TimeoutContext(@Nonnull String stage, long connectionStartNs, @Nonnull String playerIdentifier) Creates an instance of aTimeoutContextrecord class.- Parameters:
stage- the value for thestagerecord componentconnectionStartNs- the value for theconnectionStartNsrecord componentplayerIdentifier- the value for theplayerIdentifierrecord 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
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
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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
stage
-
connectionStartNs
public long connectionStartNs()Returns the value of theconnectionStartNsrecord component.- Returns:
- the value of the
connectionStartNsrecord component
-
playerIdentifier
Returns the value of theplayerIdentifierrecord component.- Returns:
- the value of the
playerIdentifierrecord component
-