Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- flush()
- write(ToClientPacket)
- writeAndFlush(ToClientPacket)
- write(ToClientPacket[])
- writeAndFlush(ToClientPacket[])
- isActive()
- isWritable()
- remoteAddress()
- formatRemoteAddress()
- disconnect(FormattedMessage)
- getPacketStatsRecorder()
- getSniHostname()
- isFromSameOrigin(ChannelConnection)
- execute(Runnable)
- setupAuxiliaryChannels(ConnectionHandler, BiConsumer)
- setChannelHandler(ConnectionHandler)
- getClientCertificate()
- updateStreamPriority(int, boolean)
- initTimeoutContext(String, String)
- updateTimeoutContext(String, String)
- updateTimeoutContext(String)
- setPacketTimeout(Duration)
- clearPacketTimeout()
- setStageTimeout(String, Duration, BooleanSupplier, Runnable)
- clearStageTimeout()
- logConnectionTimings(String, Level)
- closeConnection()
- closeApplicationConnection()
- closeApplicationConnection(QuicApplicationErrorCode)
- closeApplicationConnection(QuicApplicationErrorCode, FormattedMessage)
- equals(Object)
- hashCode()
- toString()
- channel()
Record Class NettyUtil.NettyChannelConnection
java.lang.Object
java.lang.Record
com.hypixel.hytale.server.core.io.netty.NettyUtil.NettyChannelConnection
- All Implemented Interfaces:
ChannelConnection
- Enclosing class:
NettyUtil
public static record NettyUtil.NettyChannelConnection(io.netty.channel.Channel channel)
extends Record
implements ChannelConnection
-
Constructor Summary
ConstructorsConstructorDescriptionNettyChannelConnection(io.netty.channel.Channel channel) Creates an instance of aNettyChannelConnectionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionio.netty.channel.Channelchannel()Returns the value of thechannelrecord component.voidCancels any currently scheduled packet read timeout.voidCancels any currently scheduled stage timeout.voidCloses the connection gracefully as an application-level close with no error.voidCloses the connection gracefully with a specific application error code.voidcloseApplicationConnection(QuicApplicationErrorCode errorCode, FormattedMessage reason) Closes the connection gracefully with an application error code and reason message.voidvoiddisconnect(FormattedMessage message) booleanIndicates whether some other object is "equal to" this one.voidvoidflush()inthashCode()Returns a hash code value for this object.voidinitTimeoutContext(String stage, String identifier) Initializes the timeout context for a new connection.booleanisActive()booleanTests if this connection andothercome from the same remote origin.booleanvoidlogConnectionTimings(String message, Level level) Logs connection timing information, tracking the time delta between consecutive calls.voidsetChannelHandler(ConnectionHandler handler) Replaces the current packet handler on this connection.voidsetPacketTimeout(Duration timeout) Sets the packet read timeout for the decoder.voidsetStageTimeout(String stage, Duration timeout, BooleanSupplier condition, Runnable onTimeout) Schedules a stage timeout that fires the given callback if the condition is not met within the specified duration.setupAuxiliaryChannels(ConnectionHandler handler, BiConsumer<NetworkChannel, ChannelConnection> onChannelReady) Creates auxiliary network channels (e.g., Chunks, WorldMap) for this connection.toString()Returns a string representation of this record class.voidupdateStreamPriority(int urgency, boolean incremental) Updates the QUIC stream priority for this connection's stream.voidupdateTimeoutContext(String stage) Updates the timeout context with a new stage, keeping the existing identifier.voidupdateTimeoutContext(String stage, String identifier) Updates the timeout context with a new stage and identifier.voidwrite(ToClientPacket packet) voidwrite(ToClientPacket[] packets) voidwriteAndFlush(ToClientPacket packet) voidwriteAndFlush(ToClientPacket[] packets)
-
Constructor Details
-
NettyChannelConnection
public NettyChannelConnection(io.netty.channel.Channel channel) Creates an instance of aNettyChannelConnectionrecord class.- Parameters:
channel- the value for thechannelrecord component
-
-
Method Details
-
flush
public void flush()- Specified by:
flushin interfaceChannelConnection
-
write
- Specified by:
writein interfaceChannelConnection
-
writeAndFlush
- Specified by:
writeAndFlushin interfaceChannelConnection
-
write
- Specified by:
writein interfaceChannelConnection
-
writeAndFlush
- Specified by:
writeAndFlushin interfaceChannelConnection
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceChannelConnection
-
isWritable
public boolean isWritable()- Specified by:
isWritablein interfaceChannelConnection
-
remoteAddress
- Specified by:
remoteAddressin interfaceChannelConnection
-
formatRemoteAddress
- Specified by:
formatRemoteAddressin interfaceChannelConnection
-
disconnect
- Specified by:
disconnectin interfaceChannelConnection
-
getPacketStatsRecorder
- Specified by:
getPacketStatsRecorderin interfaceChannelConnection
-
getSniHostname
- Specified by:
getSniHostnamein interfaceChannelConnection
-
isFromSameOrigin
Description copied from interface:ChannelConnectionTests if this connection andothercome from the same remote origin. A reconnecting player opens a new connection, so this must compare remote addresses. It must not compare connection identity, which is never equal across two connections. Implementations delegate toConnectionOrigin.isFromSameOrigin(SocketAddress, SocketAddress).- Specified by:
isFromSameOriginin interfaceChannelConnection- Parameters:
other- the connection to compare against- Returns:
trueif both connections are from the same origin
-
execute
- Specified by:
executein interfaceChannelConnection
-
setupAuxiliaryChannels
@Nonnull public CompletableFuture<Void> setupAuxiliaryChannels(@Nonnull ConnectionHandler handler, @Nonnull BiConsumer<NetworkChannel, ChannelConnection> onChannelReady) Description copied from interface:ChannelConnectionCreates auxiliary network channels (e.g., Chunks, WorldMap) for this connection. For multiplexed transports (QUIC), creates separate unidirectional streams.- Specified by:
setupAuxiliaryChannelsin interfaceChannelConnection- Parameters:
handler- The connection handler for pipeline setup on new streams.onChannelReady- Called for each auxiliary channel when it is ready, with theNetworkChanneland the correspondingChannelConnection.- Returns:
- a future that completes when all auxiliary channels are set up.
-
setChannelHandler
Description copied from interface:ChannelConnectionReplaces the current packet handler on this connection. Manages lifecycle callbacks (unregistered/registered) on old and new handlers.- Specified by:
setChannelHandlerin interfaceChannelConnection- Parameters:
handler- The new handler to set
-
getClientCertificate
- Specified by:
getClientCertificatein interfaceChannelConnection
-
updateStreamPriority
public void updateStreamPriority(int urgency, boolean incremental) Description copied from interface:ChannelConnectionUpdates the QUIC stream priority for this connection's stream. Lower urgency values indicate higher priority. Incremental streams may be interleaved with other streams at the same urgency level.- Specified by:
updateStreamPriorityin interfaceChannelConnection- Parameters:
urgency- The urgency level (0 = highest priority)incremental- Whether this stream's data can be interleaved with other streams
-
initTimeoutContext
Description copied from interface:ChannelConnectionInitializes the timeout context for a new connection. Call this once when the first handler is registered.- Specified by:
initTimeoutContextin interfaceChannelConnection- Parameters:
stage- The initial stage name.identifier- The player identifier (typically remote address at this point).
-
updateTimeoutContext
Description copied from interface:ChannelConnectionUpdates the timeout context with a new stage and identifier.- Specified by:
updateTimeoutContextin interfaceChannelConnection- Parameters:
stage- The new stage name.identifier- The new player identifier.
-
updateTimeoutContext
Description copied from interface:ChannelConnectionUpdates the timeout context with a new stage, keeping the existing identifier.- Specified by:
updateTimeoutContextin interfaceChannelConnection- Parameters:
stage- The new stage name.
-
setPacketTimeout
Description copied from interface:ChannelConnectionSets the packet read timeout for the decoder.- Specified by:
setPacketTimeoutin interfaceChannelConnection- Parameters:
timeout- The timeout duration.
-
clearPacketTimeout
public void clearPacketTimeout()Description copied from interface:ChannelConnectionCancels any currently scheduled packet read timeout.- Specified by:
clearPacketTimeoutin interfaceChannelConnection
-
setStageTimeout
public void setStageTimeout(@Nonnull String stage, @Nonnull Duration timeout, @Nonnull BooleanSupplier condition, @Nonnull Runnable onTimeout) Description copied from interface:ChannelConnectionSchedules a stage timeout that fires the given callback if the condition is not met within the specified duration. Cancels any previously scheduled stage timeout.- Specified by:
setStageTimeoutin interfaceChannelConnection- Parameters:
stage- The stage name (for logging).timeout- The timeout duration.condition- Returns true if the stage completed successfully (timeout should not fire).onTimeout- Callback to run when the timeout fires and the condition is not met.
-
clearStageTimeout
public void clearStageTimeout()Description copied from interface:ChannelConnectionCancels any currently scheduled stage timeout.- Specified by:
clearStageTimeoutin interfaceChannelConnection
-
logConnectionTimings
Description copied from interface:ChannelConnectionLogs connection timing information, tracking the time delta between consecutive calls.- Specified by:
logConnectionTimingsin interfaceChannelConnection- Parameters:
message- The message describing the event.level- The log level.
-
closeConnection
public void closeConnection()- Specified by:
closeConnectionin interfaceChannelConnection
-
closeApplicationConnection
public void closeApplicationConnection()Description copied from interface:ChannelConnectionCloses the connection gracefully as an application-level close with no error. Use this after sending a Disconnect packet for clean shutdown.- Specified by:
closeApplicationConnectionin interfaceChannelConnection
-
closeApplicationConnection
Description copied from interface:ChannelConnectionCloses the connection gracefully with a specific application error code. For QUIC, sends an APPLICATION_CLOSE frame to properly notify the client.- Specified by:
closeApplicationConnectionin interfaceChannelConnection- Parameters:
errorCode- Application-defined error code
-
closeApplicationConnection
public void closeApplicationConnection(@Nonnull QuicApplicationErrorCode errorCode, @Nonnull FormattedMessage reason) Description copied from interface:ChannelConnectionCloses the connection gracefully with an application error code and reason message. The reason is serialized as aFormattedMessageinto the QUIC CONNECTION_CLOSE frame so the peer can render a localized disconnect reason.- Specified by:
closeApplicationConnectionin interfaceChannelConnection- Parameters:
errorCode- Application-defined error codereason- Reason message carried in the CONNECTION_CLOSE reason phrase
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
hashCode
-
toString
-
channel
public io.netty.channel.Channel channel()Returns the value of thechannelrecord component.- Returns:
- the value of the
channelrecord component
-