KgpImageStore
Namespace: Hex1b
Assembly: Hex1b.dll
Central store for KGP images. Manages image IDs, image numbers, chunked transfers, and storage quotas.
public sealed class KgpImageStoreInheritance
Object → KgpImageStore
Constructors
KgpImageStore(long)
Creates a new image store with the specified storage quota.
Parameters:
quotaBytes(Int64): Maximum total image data size in bytes. Default: 320MB (matching kitty).
public KgpImageStore(long quotaBytes = 335544320)Properties
ImageCount
Number of images currently stored.
Returns: Int32
public int ImageCount { get; }IsChunkedTransferInProgress
Whether a chunked transfer is in progress.
Returns: Boolean
public bool IsChunkedTransferInProgress { get; }TotalSize
Total size of all stored image data in bytes.
Returns: Int64
public long TotalSize { get; }Methods
AbortChunkedTransfer()
Aborts any in-progress chunked transfer.
public void AbortChunkedTransfer()AllocateId()
Allocates a unique image ID.
Returns: UInt32
public uint AllocateId()Clear()
Removes all images.
public void Clear()GetImageById(uint)
Gets an image by its ID.
Parameters:
imageId(UInt32):
Returns: KgpImageData
public KgpImageData? GetImageById(uint imageId)GetImageByNumber(uint)
Gets the newest image with the specified image number.
Parameters:
imageNumber(UInt32):
Returns: KgpImageData
public KgpImageData? GetImageByNumber(uint imageNumber)ProcessChunk(KgpCommand, byte[])
Begins or continues a chunked transfer. Returns the completed image when the final chunk arrives.
Parameters:
command(KgpCommand): The KGP command for this chunk.decodedData(Byte[]): The base64-decoded payload data for this chunk.
Returns: KgpImageData
The completed when the final chunk (m=0) is received, or null if more chunks are expected.
public KgpImageData? ProcessChunk(KgpCommand command, byte[] decodedData)RemoveImage(uint)
Removes an image by its ID.
Parameters:
imageId(UInt32):
Returns: Boolean
True if the image was found and removed.
public bool RemoveImage(uint imageId)RemoveImageByNumber(uint)
Removes the newest image with the specified number.
Parameters:
imageNumber(UInt32):
Returns: Boolean
True if an image was found and removed.
public bool RemoveImageByNumber(uint imageNumber)StoreImage(KgpImageData)
Stores an image. If an image with the same ID already exists, it is replaced.
Parameters:
image(KgpImageData):
Returns: KgpImageData
The stored image, or null if quota would be exceeded and no eviction possible.
public KgpImageData? StoreImage(KgpImageData image)Remarks
Thread-safe. All public methods are synchronized.