Class EventChunkHandlerFactory
java.lang.Object
eu.cloudnetservice.driver.network.chunk.defaults.factory.EventChunkHandlerFactory
- All Implemented Interfaces:
Function<ChunkSessionInformation,ChunkedPacketHandler>
public class EventChunkHandlerFactory
extends Object
implements Function<ChunkSessionInformation,ChunkedPacketHandler>
Represents a factory for chunked packet handlers using the
ChunkedPacketSessionOpenEvent to determine which
handler to use for a chunked session.- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEventChunkHandlerFactory(@NonNull EventManager eventManager) Constructs a new event chunk handler factory instance. -
Method Summary
Modifier and TypeMethodDescriptionGet a new handler for the given session information based on the event call result (and therefore the result a listener of theChunkedPacketSessionOpenEventset).static @NonNull EventChunkHandlerFactorywithEventManager(@NonNull EventManager manager) Constructs a new instance of this factory using the given event manager.
-
Field Details
-
eventManager
-
-
Constructor Details
-
EventChunkHandlerFactory
Constructs a new event chunk handler factory instance. This constructor should only be used when extending from the class, seewithEventManager(EventManager)instead.- Parameters:
eventManager- the event manager to use to call events.- Throws:
NullPointerException- if the given event manager is null.
-
-
Method Details
-
withEventManager
@NonNull public static @NonNull EventChunkHandlerFactory withEventManager(@NonNull @NonNull EventManager manager) Constructs a new instance of this factory using the given event manager. The given event manager will be used to call the event, therefore the event manager must also hold the listeners which are responsible to set the factory.- Parameters:
manager- the event manager to use for this factory.- Returns:
- a new factory using the given event manager.
- Throws:
NullPointerException- if the given event manager is null.
-
apply
Get a new handler for the given session information based on the event call result (and therefore the result a listener of theChunkedPacketSessionOpenEventset).- Specified by:
applyin interfaceFunction<ChunkSessionInformation,ChunkedPacketHandler> - Parameters:
info- the session info to get the handler for.- Returns:
- the packet handler for the session set by the last listener in the chain.
- Throws:
IllegalStateException- if no listener in the chain set a handler.NullPointerException- if the given session info is null.
-