Class ChunkedSessionRegistry
java.lang.Object
eu.cloudnetservice.driver.impl.network.chunk.ChunkedSessionRegistry
A registry for chunked transfer sessions that are currently running and active.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompleteSession(@NonNull UUID sessionId) Marks the given session as completed by removing it from the lookup registry.@NonNull eu.cloudnetservice.driver.network.chunk.ChunkedPacketHandlergetOrCreateSession(@NonNull UUID sessionId, @NonNull Supplier<eu.cloudnetservice.driver.network.chunk.ChunkedPacketHandler> sessionFactory) Gets the currently active session or creates a new session using the given instance factory.voidregisterSession(@NonNull UUID sessionId, @NonNull eu.cloudnetservice.driver.network.chunk.ChunkedPacketHandler handler) Registers the given handler for the given session id, unless another handler is already registered.
-
Field Details
-
runningSessions
-
-
Constructor Details
-
ChunkedSessionRegistry
public ChunkedSessionRegistry()
-
-
Method Details
-
completeSession
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 eu.cloudnetservice.driver.network.chunk.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
@NonNull public @NonNull eu.cloudnetservice.driver.network.chunk.ChunkedPacketHandler getOrCreateSession(@NonNull @NonNull UUID sessionId, @NonNull @NonNull Supplier<eu.cloudnetservice.driver.network.chunk.ChunkedPacketHandler> sessionFactory) Gets the currently active session or creates a new session using the given instance factory. Sessions are unique by their session id. Accessing this method concurrently to create a new session will return the same session instance to all callers.- Parameters:
sessionId- the id of the session to get the current handler 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 id or session factory is null.
-