java.lang.Object
eu.cloudnetservice.driver.network.protocol.BasePacket
eu.cloudnetservice.driver.network.chunk.network.ChunkedPacket
All Implemented Interfaces:
Packet

public class ChunkedPacket extends BasePacket
A chunked packet which gets transferred from the sender to the target each time holding necessary information for packet processing on the other side.
Since:
4.0
  • Constructor Details

  • Method Details

    • createChunk

      @NonNull public static @NonNull ChunkedPacket createChunk(@NonNull @NonNull ChunkSessionInformation information, int chunkIndex, byte[] data)
      Creates a new chunk part. This method is used when the full chunk data is not yet known. It gives no information about the amount of chunks in the full transfer and uses the length of the given array as the data length.

      This call is equivalent to ChunkedPacket.createChunk(information, null, chunkIndex, data.length, data).

      Parameters:
      information - the session information this chunk belongs to.
      chunkIndex - the index of the written chunk.
      data - the data of the chunk.
      Returns:
      the created chunk packet based on the information.
      Throws:
      NullPointerException - if the given chunk information is null.
    • createChunk

      @NonNull public static @NonNull ChunkedPacket createChunk(@NonNull @NonNull ChunkSessionInformation information, @Nullable @Nullable Integer chunkAmount, int chunkIndex, int dataLength, byte[] data)
      Creates a new chunk part based on the given information. This method is used primarily to create a chunk part when all information needed to complete the transfer are available (normally when the last chunk was read from the backing stream)
      Parameters:
      information - the session information this chunk belongs to.
      chunkAmount - the amount of chunks which were read from the backing buffer.
      chunkIndex - the index of the written chunk.
      dataLength - the amount of bytes in the current packet chunk.
      data - the data of the chunk.
      Returns:
      the created chunk packet based on the information.
      Throws:
      NullPointerException - if the given chunk information is null.