Class ChunkedPacketListener
java.lang.Object
eu.cloudnetservice.driver.network.chunk.network.ChunkedPacketListener
- All Implemented Interfaces:
PacketListener
A listener for chunked packets, opening the chunked pocket sessions.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Function<ChunkSessionInformation, ChunkedPacketHandler> private final ChunkedSessionRegistry -
Constructor Summary
ConstructorsConstructorDescriptionChunkedPacketListener(@NonNull ChunkedSessionRegistry sessionRegistry, @NonNull Function<ChunkSessionInformation, ChunkedPacketHandler> handlerFactory) Creates a new packet listener instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(@NonNull NetworkChannel channel, @NonNull Packet packet) Handles the incoming packet.
-
Field Details
-
sessionRegistry
-
handlerFactory
-
-
Constructor Details
-
ChunkedPacketListener
public ChunkedPacketListener(@NonNull @NonNull ChunkedSessionRegistry sessionRegistry, @NonNull @NonNull Function<ChunkSessionInformation, ChunkedPacketHandler> handlerFactory) Creates a new packet listener instance.- Parameters:
handlerFactory- the factory to create the chunked packet handlers when receiving the initial request.- Throws:
NullPointerException- if the given factory is null.
-
-
Method Details
-
handle
public void handle(@NonNull @NonNull NetworkChannel channel, @NonNull @NonNull Packet packet) throws Exception Handles the incoming packet. A packet handle should be release-safe and transactional to preserve the content of the packet for listeners which are following in the chain. If a packet listener is not doing that, it might lead to unexpected exceptions in other packet listener implementations for the same packet.- Specified by:
handlein interfacePacketListener- Parameters:
channel- the channel from which the original packet came.packet- the packet which was received.- Throws:
Exception- if any exception occurs during handling of the packet.
-