Class ChunkedSessionRegistry

java.lang.Object
eu.cloudnetservice.driver.network.chunk.defaults.ChunkedSessionRegistry

@Singleton public final class ChunkedSessionRegistry extends Object
A registry for chunked transfer sessions that are currently running and active.
Since:
4.0
  • Field Details

  • Constructor Details

    • ChunkedSessionRegistry

      public ChunkedSessionRegistry()
  • Method Details

    • completeSession

      public void completeSession(@NonNull @NonNull UUID sessionId)
      Marks the given session as completed by removing it from the lookup registry. Further tries to access a session with the given unique id will create a new session instead.
      Parameters:
      sessionId - the id of the session to mark as completed.
      Throws:
      NullPointerException - if the given session id is null.
    • registerSession

      public void registerSession(@NonNull @NonNull UUID sessionId, @NonNull @NonNull ChunkedPacketHandler handler)
      Registers the given handler for the given session id, unless another handler is already registered.
      Parameters:
      sessionId - the session id to register the handler for.
      handler - the handler to register for the session id.
      Throws:
      NullPointerException - if the given session id or handler is null.
    • getOrCreateSession

      Gets the currently active session or creates a new session using the given instance factory. Sessions are unique by their session id. Concurrently accessing this method to create a new session will return the same session instance to all callers.
      Parameters:
      sessionInformation - the information of the session to get or create the session of.
      sessionFactory - the factory to call if no session is currently associated with the session id.
      Returns:
      the existing registered or newly created transfer session for the provided session id.
      Throws:
      NullPointerException - if the given session information or session factory is null.