Contents
Class PacketDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
com.hypixel.hytale.protocol.io.netty.PacketDecoder
- All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
public class PacketDecoder
extends io.netty.handler.codec.ByteToMessageDecoder
Netty decoder for the protocol. Handles length-prefixed framing and packet-level timeouts.
Wire format: [4-byte payload length] [4-byte packet ID] [payload]
Timeout handling: - Tracks time since last complete packet was decoded - Reads timeout duration from channel attribute (set by server) - Fires ReadTimeoutException if no complete packet arrives within timeout - Handles both "no data" and "trickle data" scenarios
Early validation silently closes connections for obviously malformed packets to avoid exception overhead and DoS amplification via Sentry logging.
Validation order (fail-fast for DoS resistance): 1. Payload length bounds (don't wait for data if length is invalid) 2. Packet ID validity (don't wait for payload if ID is unknown) 3. Payload size vs max for this packet type
-
Nested Class Summary
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
channelRead, channelReadComplete, handlerRemoved, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class io.netty.channel.ChannelHandlerAdapter
isSharable
-
Constructor Details
-
PacketDecoder
public PacketDecoder()
-
-
Method Details
-
handlerAdded
-
channelActive
-
channelInactive
-