Class StreamManager

java.lang.Object
com.hypixel.hytale.server.core.io.stream.StreamManager

public class StreamManager extends Object
Manages typed QUIC stream handlers and their stream priorities. Stream handlers can be registered for specific stream types, and will be created when clients open streams of that type.
  • Field Details

    • MAX_AUXILIARY_STREAMS

      public static final int MAX_AUXILIARY_STREAMS
      Maximum number of auxiliary streams a single connection may have open simultaneously.
      See Also:
    • GAME_STREAM_PRIORITY

      public static final io.netty.handler.codec.quic.QuicStreamPriority GAME_STREAM_PRIORITY
      QUIC stream priority for the game stream (stream 0). Urgency 0 = highest priority, non-incremental = game state must arrive before anything else.
    • DEFAULT_AUXILIARY_PRIORITY

      public static final io.netty.handler.codec.quic.QuicStreamPriority DEFAULT_AUXILIARY_PRIORITY
      Default QUIC stream priority for auxiliary streams that don't specify one. Urgency 64, non-incremental.
  • Method Details

    • getInstance

      @Nonnull public static StreamManager getInstance()
      Gets the singleton StreamManager instance.
      Returns:
      The StreamManager instance
    • registerHandler

      public void registerHandler(@Nonnull StreamType type, @Nonnull StreamManager.StreamHandlerFactory factory)
      Registers a handler factory for a stream type with the default auxiliary priority.
      Parameters:
      type - The stream type to handle
      factory - The factory that creates handlers for this stream type
    • registerHandler

      public void registerHandler(@Nonnull StreamType type, @Nonnull StreamManager.StreamHandlerFactory factory, @Nonnull io.netty.handler.codec.quic.QuicStreamPriority priority)
      Registers a handler factory for a stream type with a specific QUIC stream priority.

      Example (plugin registering a voice stream with low-priority incremental delivery):

      StreamManager.getInstance().registerHandler(
          StreamType.Voice,
          packetHandler -> new VoiceStreamHandler(packetHandler),
          new QuicStreamPriority(127, true)
      );
      
      Parameters:
      type - The stream type to handle
      factory - The factory that creates handlers for this stream type
      priority - The QUIC stream priority (lower urgency = higher priority)
    • unregisterHandler

      public void unregisterHandler(@Nonnull StreamType type)
      Unregisters a handler factory for a stream type.
      Parameters:
      type - The stream type to unregister
    • isSupported

      public boolean isSupported(@Nonnull StreamType type)
      Checks if a stream type has a registered handler.
      Parameters:
      type - The stream type to check
      Returns:
      true if the stream type is supported
    • createHandler

      @Nullable public ConnectionHandler createHandler(@Nonnull StreamType type, @Nonnull PacketHandler packetHandler, @Nonnull ChannelConnection channel)
      Creates a handler for a stream type.
      Parameters:
      type - The stream type
      packetHandler - The main packet handler for the connection
      channel - The channel connection for the new stream
      Returns:
      A new handler for the stream, or null if the type is not supported
    • clearAll

      public void clearAll()
      Removes all registered handlers. Intended for test isolation and plugin reload scenarios.
    • getStreamPriority

      @Nonnull public io.netty.handler.codec.quic.QuicStreamPriority getStreamPriority(@Nonnull StreamType type)
      Gets the QUIC stream priority for a stream type.
      Parameters:
      type - The stream type
      Returns:
      The priority for this stream type, or DEFAULT_AUXILIARY_PRIORITY if not registered